Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custom connection in database migrations #118

Merged
merged 4 commits into from
Sep 13, 2019

Conversation

antonkomarev
Copy link
Member

@antonkomarev antonkomarev commented Sep 13, 2019

Resolves #116

@vesper8 found that Migration's getConnection() method is used only for resolving if connection supports schema transactions, but never used in migration itself.

protected function runMigration($migration, $method)
{
    $connection = $this->resolveConnection(
        $migration->getConnection()
    );

    $callback = function () use ($migration, $method) {
        if (method_exists($migration, $method)) {
            $this->fireMigrationEvent(new MigrationStarted($migration, $method));

            $migration->{$method}();

            $this->fireMigrationEvent(new MigrationEnded($migration, $method));
        }
    };

    $this->getSchemaGrammar($connection)->supportsSchemaTransactions()
        && $migration->withinTransaction
                ? $connection->transaction($callback)
                : $callback();
}

So I've added protected $schema property with configured connection.

Additionally this PR fixes missing Schema configuration in love:setup-reacterable & love:setup-reactable commands.

@antonkomarev antonkomarev changed the title Fix custom connection in migrations Fix custom connection in database migrations Sep 13, 2019
@antonkomarev antonkomarev merged commit 6aec097 into master Sep 13, 2019
@antonkomarev antonkomarev deleted the fix/separate-database-connection-config branch September 13, 2019 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

custom database configuration is ignored
1 participant