@@ -141,10 +141,7 @@ public function __construct(MigrationsConfig $config, $db = null)
141141 // Default name space is the app namespace
142142 $ this ->namespace = APP_NAMESPACE ;
143143
144- // get default database group
145- $ config = config (Database::class);
146- $ this ->group = $ config ->defaultGroup ;
147- unset($ config );
144+ $ this ->group = is_string ($ db ) ? $ db : config (Database::class)->defaultGroup ;
148145
149146 // If no db connection passed in, use
150147 // default database group.
@@ -841,7 +838,7 @@ protected function migrate($direction, $migration): bool
841838
842839 /** @var Migration $instance */
843840 $ instance = new $ class (Database::forge ($ this ->db ));
844- $ group = $ instance ->getDBGroup () ?? config (Database::class)-> defaultGroup ;
841+ $ group = $ instance ->getDBGroup () ?? $ this -> group ;
845842
846843 if (ENVIRONMENT !== 'testing ' && $ group === 'tests ' && $ this ->groupFilter !== 'tests ' ) {
847844 // @codeCoverageIgnoreStart
@@ -857,8 +854,6 @@ protected function migrate($direction, $migration): bool
857854 return true ;
858855 }
859856
860- $ this ->setGroup ($ group );
861-
862857 if (! is_callable ([$ instance , $ direction ])) {
863858 $ message = sprintf (lang ('Migrations.missingMethod ' ), $ direction );
864859
0 commit comments