1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 06:04:03 +00:00

Update Migrate command

This commit is contained in:
lukinovec 2023-01-06 06:35:23 +01:00
parent 146570f7e9
commit bfd2669fda

View file

@ -46,24 +46,24 @@ class Migrate extends MigrateCommand
return 1;
}
try {
tenancy()->runForMultiple($this->option('tenants'), function ($tenant) {
$this->line("Tenant: {$tenant->getTenantKey()}");
foreach ($this->option('tenants') as $tenant) {
try {
tenancy()->find($tenant)->run(function($tenant) {
$this->line("Tenant: {$tenant->getTenantKey()}");
event(new MigratingDatabase($tenant));
// Migrate
parent::handle();
event(new MigratingDatabase($tenant));
// Migrate
parent::handle();
event(new DatabaseMigrated($tenant));
});
return 0;
} catch (TenantDatabaseDoesNotExistException|QueryException $th) {
if (! $this->option('skip-failing')) {
throw $th;
event(new DatabaseMigrated($tenant));
});
} catch (TenantDatabaseDoesNotExistException|QueryException $th) {
if (! $this->option('skip-failing')) {
throw $th;
}
}
return 1;
}
return 0;
}
}