You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have my own database migration for a multi-tenant system. This has been working for years (since Laravel 6) and all of a sudden when I upgraded from 9.20.0 to 9.21.0 it broke.
Each of my tenants has their own database and I run a migration on the new database to create all of the tables.
It used to run my migrations perfectly. Now, it does create a migrations table in the tenant database with all of the migration files as rows, but none of the actual tables are created. It's an empty database except for a single "migrations" table.
// This is an artisan command
protected $migrator;
public function __construct()
{
parent::__construct();
$this->migrator = app('migrator');
}
public function handle()
{
// up here I get a Tenant and set it to $tenant
$this->migrate($tenant);
}
private function migrate(Tenant $tenant)
{
$this->prepareDatabase($tenant);
$databasePath = database_path('migrations/tenants'); // this directory has all of the tenant-specific migration files
Log::debug("Running migration for databasePath: $databasePath");
$this->migrator->run($databasePath, []);
}
protected function prepareDatabase(Tenant $tenant)
{
$this->migrator->setConnection(Config::get('database.tenant_default'));
Config::set('database.connections.tenant-remote.database', $tenant->getDatabaseName());
if (!$this->migrator->repositoryExists()) {
Log::debug("Repository does not exist, running migrate:install");
$this->call('migrate:install');
}
}
I was looking through the fixes added to this version and can't seem to figure out what would have broken my code but when I revert the framework back to 9.20.0 it does work like it always has, but when I bring it back up to 9.21.0, it no longer creates my database tables as it should.
The text was updated successfully, but these errors were encountered:
nunomaduro
changed the title
Custom database migration in 9.21.0 does not work like it did in 9.20.0
[9.x] Custom database migration in 9.21.0 does not work like it did in 9.20.0
Jul 20, 2022
Description:
Hi,
I have my own database migration for a multi-tenant system. This has been working for years (since Laravel 6) and all of a sudden when I upgraded from 9.20.0 to 9.21.0 it broke.
Each of my tenants has their own database and I run a migration on the new database to create all of the tables.
It used to run my migrations perfectly. Now, it does create a migrations table in the tenant database with all of the migration files as rows, but none of the actual tables are created. It's an empty database except for a single "migrations" table.
I was looking through the fixes added to this version and can't seem to figure out what would have broken my code but when I revert the framework back to 9.20.0 it does work like it always has, but when I bring it back up to 9.21.0, it no longer creates my database tables as it should.
The text was updated successfully, but these errors were encountered: