1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 21:34:04 +00:00

Add drop of db views on migrate fresh command (#812)

* Optionally handle drop of table views on MigrateFresh

@stancl I managed to make the modification discussed here #811 
Afaik (and I can understand) this is the easiest way to handle it, but I'm open to discuss.

* Remove redundant store variable

* code style

Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
masiorama 2022-02-22 16:26:07 +01:00 committed by GitHub
parent 5b9b384526
commit b4a4eab949
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@ namespace Stancl\Tenancy\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Stancl\Tenancy\Concerns\DealsWithMigrations; use Stancl\Tenancy\Concerns\DealsWithMigrations;
use Stancl\Tenancy\Concerns\HasATenantsOption; use Stancl\Tenancy\Concerns\HasATenantsOption;
use Symfony\Component\Console\Input\InputOption;
final class MigrateFresh extends Command final class MigrateFresh extends Command
{ {
@ -23,6 +24,8 @@ final class MigrateFresh extends Command
{ {
parent::__construct(); parent::__construct();
$this->addOption('--drop-views', null, InputOption::VALUE_NONE, 'Drop views along with tenant tables.', null);
$this->setName('tenants:migrate-fresh'); $this->setName('tenants:migrate-fresh');
} }
@ -37,6 +40,7 @@ final class MigrateFresh extends Command
$this->info('Dropping tables.'); $this->info('Dropping tables.');
$this->call('db:wipe', array_filter([ $this->call('db:wipe', array_filter([
'--database' => 'tenant', '--database' => 'tenant',
'--drop-views' => $this->option('drop-views'),
'--force' => true, '--force' => true,
])); ]));