1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 06:54:03 +00:00

Bootstrapper tests

This commit is contained in:
Samuel Štancl 2020-05-11 03:37:47 +02:00
parent 73fc525126
commit 6f4b9f486c
20 changed files with 266 additions and 79 deletions

View file

@ -7,6 +7,7 @@ namespace Stancl\Tenancy\Commands;
use Illuminate\Console\Command;
use Illuminate\Database\Console\Migrations\MigrateCommand;
use Illuminate\Database\Migrations\Migrator;
use Stancl\Tenancy\Contracts\TenantWithDatabase;
use Stancl\Tenancy\DatabaseManager;
use Stancl\Tenancy\Events\DatabaseMigrated;
use Stancl\Tenancy\Traits\DealsWithMigrations;
@ -56,15 +57,20 @@ class Migrate extends MigrateCommand
return;
}
tenancy()->all($this->option('tenants'))->each(function ($tenant) {
$this->line("Tenant: {$tenant['id']}");
tenancy()
->query()
->when($this->option('tenants'), function ($query) {
$query->whereIn(tenancy()->model()->getTenantKeyName(), $this->option('tenants'));
})
->each(function (TenantWithDatabase $tenant) {
$this->line("Tenant: {$tenant['id']}");
$tenant->run(function () {
// Migrate
parent::handle();
$tenant->run(function () {
// Migrate
parent::handle();
});
event(new DatabaseMigrated($tenant));
});
event(new DatabaseMigrated($tenant));
});
}
}