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

Seed after migration ignores --force flag in config/tenancy.php on production environment #367

Closed
jgb-ibsa opened this issue Apr 23, 2020 · 7 comments · Fixed by #368
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jgb-ibsa
Copy link

Describe the bug

We have an application running on 3 different environments. local, testing and production. We use the seed_after_migration configuration and set '--force' => true. This works perfectly on all environments except production.

Steps to reproduce

You will be able to reproduce this issue by setting environment to production, 'seed_after_migration' => true and '--force' => true. No errors will be thrown, the database will not seed.

Expected behavior

The Database should seed as expected after migration.

Your setup

  • Laravel 7.7.1
  • stancl/tenancy 2.3.4
  • Using Postgres

Workaround

When removing the following lines (46,47,48) from Stancl\Tenancy\Commands\Seed.php this issue is not experienced. Is it possible that the force flag is being ignored.

if (! $this->confirmToProceed()) {
    return;
}
@jgb-ibsa jgb-ibsa added the bug Something isn't working label Apr 23, 2020
@techguydev
Copy link

techguydev commented Apr 23, 2020 via email

@jgb-ibsa
Copy link
Author

As a temporary workaround we have added the following within the run section when creating a new tenant.

if (config('app.env') === 'production') {
    Artisan::call('tenants:seed --tenants=' . $tenant->id . ' --force');
}

@stancl
Copy link
Member

stancl commented Apr 23, 2020

@john-ibsa Does moving this block https://github.com/stancl/tenancy/blob/2.x/src/Commands/Seed.php#L55-L59

To the start of the method (i.e. before the confirmToProceed) fix this for you?

@stancl stancl added this to the 2.3.5 milestone Apr 23, 2020
@stancl
Copy link
Member

stancl commented Apr 23, 2020

I'll be tagging 2.3.5 today. So if you can confirm that this fixes the problem for you, I'll make it part of the release.

@stancl stancl removed this from the 2.3.5 milestone Apr 23, 2020
@jgb-ibsa
Copy link
Author

@stancl thanks for the quick response. This makes complete sense as the tenancy.seeder_parameters should be set to input before the confirmToProceed is called.

I have tested this update and confirmed this is now working as expected.

Appreciated.

@stancl
Copy link
Member

stancl commented Apr 23, 2020

Ah, last minute. Was just writing the release notes. Will include a patch in the release.

@stancl stancl added this to the 2.3.5 milestone Apr 23, 2020
@jgb-ibsa
Copy link
Author

I think I got that in about 12 seconds late :) Thanks @stancl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants