diff --git a/src/Commands/MigrateRefresh.php b/src/Commands/MigrateRefresh.php new file mode 100644 index 00000000..b66856cd --- /dev/null +++ b/src/Commands/MigrateRefresh.php @@ -0,0 +1,51 @@ +addOption('--path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to be executed', null); + + $this->setName('tenants:migrate-refresh'); + } + + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + tenancy()->runForMultiple($this->option('tenants'), function ($tenant) { + $this->info('Rolling back migrations.'); + $this->call('migrate:refresh', array_filter([ + '--database' => 'tenant', + '--path' => $this->option('path'), + '--force' => true, + ])); + + }); + + $this->info('Done.'); + } +} diff --git a/src/TenancyServiceProvider.php b/src/TenancyServiceProvider.php index dec8c72e..e7b226d8 100644 --- a/src/TenancyServiceProvider.php +++ b/src/TenancyServiceProvider.php @@ -90,6 +90,7 @@ class TenancyServiceProvider extends ServiceProvider Commands\Rollback::class, Commands\TenantList::class, Commands\MigrateFresh::class, + Commands\MigrateRefresh::class, ]); $this->publishes([