diff --git a/src/Commands/MigrateFresh.php b/src/Commands/MigrateFresh.php new file mode 100644 index 00000000..f343d77b --- /dev/null +++ b/src/Commands/MigrateFresh.php @@ -0,0 +1,62 @@ +getTenant(); + $this->info('Dropping tables.'); + + tenancy()->all($this->option('tenants'))->each(function ($tenant) { + $this->line("Tenant: {$tenant->id}"); + + tenancy()->initialize($tenant); + + $this->call('db:wipe', [ + '--database' => $tenant->getDatabaseName(), + '--force' => true, + ]); + + $this->call('tenants:migrate', [ + '--tenants' => [$tenant->id], + ]); + + tenancy()->end(); + }); + + $this->info('Done.'); + + if ($originalTenant) { + tenancy()->initialize($originalTenant); + } + } +}