Skip to content

Commit

Permalink
Add drop of db views on migrate fresh command (archtechx#812)
Browse files Browse the repository at this point in the history
* Optionally handle drop of table views on MigrateFresh

@stancl I managed to make the modification discussed here archtechx#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 <[email protected]>
  • Loading branch information
masiorama and stancl authored Feb 22, 2022
1 parent 5b9b384 commit b4a4eab
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Commands/MigrateFresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Console\Command;
use Stancl\Tenancy\Concerns\DealsWithMigrations;
use Stancl\Tenancy\Concerns\HasATenantsOption;
use Symfony\Component\Console\Input\InputOption;

final class MigrateFresh extends Command
{
Expand All @@ -22,6 +23,8 @@ final class MigrateFresh extends Command
public function __construct()
{
parent::__construct();

$this->addOption('--drop-views', null, InputOption::VALUE_NONE, 'Drop views along with tenant tables.', null);

$this->setName('tenants:migrate-fresh');
}
Expand All @@ -37,6 +40,7 @@ public function handle()
$this->info('Dropping tables.');
$this->call('db:wipe', array_filter([
'--database' => 'tenant',
'--drop-views' => $this->option('drop-views'),
'--force' => true,
]));

Expand Down

0 comments on commit b4a4eab

Please sign in to comment.