mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 12:24:04 +00:00
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.
This commit is contained in:
parent
5b9b384526
commit
9f83a65f22
1 changed files with 7 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ namespace Stancl\Tenancy\Commands;
|
|||
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
|
||||
{
|
||||
|
|
@ -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');
|
||||
}
|
||||
|
|
@ -33,10 +36,13 @@ final class MigrateFresh extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
tenancy()->runForMultiple($this->option('tenants'), function ($tenant) {
|
||||
$dropViewsFlag = $this->option('drop-views');
|
||||
|
||||
tenancy()->runForMultiple($this->option('tenants'), function ($tenant) use ($dropViewsFlag) {
|
||||
$this->info('Dropping tables.');
|
||||
$this->call('db:wipe', array_filter([
|
||||
'--database' => 'tenant',
|
||||
'--drop-views' => $dropViewsFlag,
|
||||
'--force' => true,
|
||||
]));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue