From 590709930347d660bf2f36727e180267f80af3f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sun, 29 Sep 2019 12:12:32 +0200 Subject: [PATCH] migrate-fresh first draft --- src/Commands/MigrateFresh.php | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/Commands/MigrateFresh.php 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); + } + } +}