@@ -141,10 +141,11 @@ 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+ if (is_string ($ db )) {
145+ $ this ->group = $ db ;
146+ } else {
147+ $ this ->group = config (Database::class)->defaultGroup ;
148+ }
148149
149150 // If no db connection passed in, use
150151 // default database group.
@@ -841,7 +842,7 @@ protected function migrate($direction, $migration): bool
841842
842843 /** @var Migration $instance */
843844 $ instance = new $ class (Database::forge ($ this ->db ));
844- $ group = $ instance ->getDBGroup () ?? config (Database::class)-> defaultGroup ;
845+ $ group = $ instance ->getDBGroup () ?? $ this -> group ;
845846
846847 if (ENVIRONMENT !== 'testing ' && $ group === 'tests ' && $ this ->groupFilter !== 'tests ' ) {
847848 // @codeCoverageIgnoreStart
@@ -857,8 +858,6 @@ protected function migrate($direction, $migration): bool
857858 return true ;
858859 }
859860
860- $ this ->setGroup ($ group );
861-
862861 if (! is_callable ([$ instance , $ direction ])) {
863862 $ message = sprintf (lang ('Migrations.missingMethod ' ), $ direction );
864863
0 commit comments