Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Fix: drop tenant databases on migrate fresh without domains #1282

Conversation

MichaelKampmann
Copy link

When running php artisan migrate:fresh in a tenacy setup without domains in combination with 'drop_tenant_databases_on_migrate_fresh' => true, an ErrorException is thrown

  ErrorException 

  Attempt to read property "each" on null

  at vendor/stancl/tenancy/src/Jobs/DeleteDomains.php:24
     20▕     ) {}
     21▕ 
     22▕     public function handle(): void
     23▕     {
  ➜  24▕         $this->tenant->domains->each->delete();
     25▕     }
     26▕ }
     27▕ 

This PR resolves the issue by setting the domains to be optional on the DeleteDomain job

Copy link

codecov bot commented Jan 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.74%. Comparing base (abe1f1f) to head (7b9e65c).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1282   +/-   ##
=========================================
  Coverage     84.74%   84.74%           
  Complexity     1025     1025           
=========================================
  Files           174      174           
  Lines          3015     3015           
=========================================
  Hits           2555     2555           
  Misses          460      460           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stancl
Copy link
Member

stancl commented Jan 1, 2025

Thanks!

@stancl stancl merged commit 6b38a35 into archtechx:master Jan 1, 2025
6 checks passed
@stancl stancl changed the title fix: drop tenant databases on migrate fresh without domains [4.x] Fix: drop tenant databases on migrate fresh without domains Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants