-
Notifications
You must be signed in to change notification settings - Fork 787
Description
I guess a a lot of people use the SeedDatabase job to create settings and other inital data for each tenant (as proposed in TenancyServiceProvider), but the proposed use case does not work in production.
In contrast to the comment inside tenancy.php and the v3 documentation, there is no hint that you need to set the --force flag to true to be able to seed tenants during the tenant creation process (cf. tenancy.php).
Also, the corresponding database_can_be_seeded_after_tenant_creation test in DatabasePreparationTest does not consider the difference based on the configured environment, hence it will succeed in everything except production.
This is misleading and I would propose to change the documentation of Configuration#SeederParameters and Console Commands#RollbackAndSeed as follows:
Configuration
### Seeder parameters {#seeder-parameters}
`tenancy.seeder_parameters`
The same as migration parameters, but for `tenants:seed` and the `SeedDatabase` job.
> Note: Set `--force`to `true` to allow seeding tenant databases in production (e. g. during tenant creation).
Console Commands
## **Rollback & seed** (tenant-aware) {#rollback-and-seed}
- Rollback: `tenants:rollback`
- Seed: `tenants:seed`
> Note: You can configure the default parameters for `tenants:seed` (e.g. use a custom tenant seeder) in [the tenancy config]({{ $page->link('configuration#seeder-parameters') }}). Be aware that the `--force` parameter needs to be set in order to seed tenants in `production`.
Also, I would add a comment in tenancy.php:
/**
* Parameters used by the tenants:seed command.
*/
'seeder_parameters' => [
'--class' => 'DatabaseSeeder', // root seeder class
// '--force' => true, // This needs to be true to seed tenant databases in production
],
I've also created a PR for this: archtechx/tenancy#1326
Thanks for your review!