mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 19:14:03 +00:00
Migrate Refresh
This commit is contained in:
parent
84a3287799
commit
eed1def819
2 changed files with 52 additions and 0 deletions
51
src/Commands/MigrateRefresh.php
Normal file
51
src/Commands/MigrateRefresh.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
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 MigrateRefresh extends Command
|
||||
{
|
||||
use HasATenantsOption, DealsWithMigrations;
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Reset and re-run all migrations';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->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.');
|
||||
}
|
||||
}
|
||||
|
|
@ -90,6 +90,7 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
Commands\Rollback::class,
|
||||
Commands\TenantList::class,
|
||||
Commands\MigrateFresh::class,
|
||||
Commands\MigrateRefresh::class,
|
||||
]);
|
||||
|
||||
$this->publishes([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue