-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
waiting for infoIssues or pull requests that need further clarification from the authorIssues or pull requests that need further clarification from the author
Description
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
$groupand pass it to$forge = \Config\Database::forge($group); - Run a migration file and outtput
$this->forgeand 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
Metadata
Metadata
Assignees
Labels
waiting for infoIssues or pull requests that need further clarification from the authorIssues or pull requests that need further clarification from the author