From 9810c4d5b3f1999b465273306babe8d2bd0fbedb Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Wed, 15 Nov 2023 18:07:08 +0800 Subject: [PATCH] Add fix --- system/Database/Config.php | 10 ++++++++++ system/Database/MigrationRunner.php | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/system/Database/Config.php b/system/Database/Config.php index 92556c6d8fef..8c2a1cf52726 100644 --- a/system/Database/Config.php +++ b/system/Database/Config.php @@ -137,6 +137,16 @@ public static function seeder(?string $group = null) return new Seeder($config, static::connect($group)); } + /** + * Returns instance of Database Factory. + */ + public static function factory(): Database + { + static::ensureFactory(); + + return static::$factory; + } + /** * Ensures the database Connection Manager/Factory is loaded and ready to use. */ diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index 241a9e6da5fa..ba279481a002 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -839,7 +839,8 @@ protected function migrate($direction, $migration): bool throw new RuntimeException($message); } - $instance = new $class(); + /** @var Migration $instance */ + $instance = new $class(Database::factory()->loadForge($this->db)); $group = $instance->getDBGroup() ?? config(Database::class)->defaultGroup; if (ENVIRONMENT !== 'testing' && $group === 'tests' && $this->groupFilter !== 'tests') {