Skip to content

Commit

Permalink
Fix setting of group
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Nov 19, 2023
1 parent d82fb2e commit c581a48
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions system/Database/MigrationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ public function __construct(MigrationsConfig $config, $db = null)
// Default name space is the app namespace
$this->namespace = APP_NAMESPACE;

// get default database group
$config = config(Database::class);
$this->group = $config->defaultGroup;
unset($config);
if (is_string($db)) {
$this->group = $db;
} else {
$this->group = config(Database::class)->defaultGroup;
}

// If no db connection passed in, use
// default database group.
Expand Down Expand Up @@ -841,7 +842,7 @@ protected function migrate($direction, $migration): bool

/** @var Migration $instance */
$instance = new $class(Database::forge($this->db));
$group = $instance->getDBGroup() ?? config(Database::class)->defaultGroup;
$group = $instance->getDBGroup() ?? $this->group;

if (ENVIRONMENT !== 'testing' && $group === 'tests' && $this->groupFilter !== 'tests') {
// @codeCoverageIgnoreStart
Expand All @@ -857,8 +858,6 @@ protected function migrate($direction, $migration): bool
return true;
}

$this->setGroup($group);

if (! is_callable([$instance, $direction])) {
$message = sprintf(lang('Migrations.missingMethod'), $direction);

Expand Down

0 comments on commit c581a48

Please sign in to comment.