Digging Deeper
Commands
The package registers four Artisan-style console commands when it is listed in
Packages. Run them with the Laravel Go CLI (laravel …) against an app
that has already migrated the central
database.
Except for tenants:list, each mutating command accepts --tenants= to limit
work to comma-separated tenant ids. Omit the flag to process every tenant.
Parallelism for migrate/seed workers is capped by MigrateConcurrency
(env: TENANCY_MIGRATE_CONCURRENCY, default 4).
tenants:list
Prints every tenant row from the central database (id, database name from
data, and single-domain hostname when present).
laravel tenants:listExample output:
acme db=tenantacme domain=acme.example.com.test
beta db=tenantbeta domain=beta.example.com.testUse this to confirm provisioning and Herd rewrites before migrating or seeding.
tenants:migrate
Opens each tenant database (via the pool) and runs Config.TenantMigrations
with Laravel’s migrator. Safe to re-run: already-applied migrations are skipped.
laravel tenants:migrate
laravel tenants:migrate --tenants=acme,betaTypical uses: after deploying new tenant schema, or after creating tenants
outside CreateTenant / auto-provision.
tenants:migrate-fresh
Drops all tables on each selected tenant database, then re-runs
Config.TenantMigrations from scratch. Destructive. Prefer this in local or
CI resets, not against production data.
laravel tenants:migrate-fresh --tenants=acmetenants:seed
For each tenant, enters a tenant context with Package.Run and calls
Config.TenantSeed. If TenantSeed is nil, the command prints a notice and
exits successfully.
tenancy.New(func(cfg *tenancy.Config) {
cfg.TenantSeed = func(ctx context.Context) error {
// ctx is already initialized for the current tenant
_, err := db.Exec(ctx, `insert into notes (body) values (?)`, "welcome")
return err
}
})laravel tenants:seed
laravel tenants:seed --tenants=acme