PHP Version
8.0
CodeIgniter4 Version
4.3.4
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
Mysql
What happened?
When running a new MigrationRunner($config, $db); we are allowed to pass in a $db as the second param. However this $db is never passed to the actual migration files which means that it will fall back to the default one when running latest/up/regress etc. Furthermore, it can't be assumed that $db is a group because it could be a custom config.
Steps to Reproduce
- Create a
$group and pass it to $forge = \Config\Database::forge($group);
- Run a migration file and outtput
$this->forge and you'll see it reverts to the default
Expected Output
The migration files should be using the same $db group / config as the Migration runner.
The solution is to:
- Amend MigrationRunner
$instance = new $class(Database::forge($this->db));
- Within your Migration files add a construct which calls the parent.
public function __construct($forge = null){
if ($forge) parent::__construct($forge);
}
Anything else?
No response
PHP Version
8.0
CodeIgniter4 Version
4.3.4
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
Mysql
What happened?
When running a
new MigrationRunner($config, $db);we are allowed to pass in a $db as the second param. However this $db is never passed to the actual migration files which means that it will fall back to the default one when running latest/up/regress etc. Furthermore, it can't be assumed that $db is a group because it could be a custom config.Steps to Reproduce
$groupand pass it to$forge = \Config\Database::forge($group);$this->forgeand you'll see it reverts to the defaultExpected Output
The migration files should be using the same $db group / config as the Migration runner.
The solution is to:
$instance = new $class(Database::forge($this->db));Anything else?
No response