Migration of non-default group is also executed without the -g option.
-g - to chose database group, otherwise default database group will be used.
https://codeigniter4.github.io/CodeIgniter4/dbmgmt/migration.html#migrate
How to Reproduce
--- a/app/Config/Database.php+++ b/app/Config/Database.php@@ -45,6 +45,47 @@ class Database extends Config
'numberNative' => false,
];
+ public array $test1 = [+ 'DSN' => '',+ 'hostname' => 'localhost',+ 'username' => 'root',+ 'password' => '',+ 'database' => 'ci4_test1',+ 'DBDriver' => 'MySQLi',+ 'DBPrefix' => '',+ 'pConnect' => false,+ 'DBDebug' => true,+ 'charset' => 'utf8',+ 'DBCollat' => 'utf8_general_ci',+ 'swapPre' => '',+ 'encrypt' => false,+ 'compress' => false,+ 'strictOn' => false,+ 'failover' => [],+ 'port' => 3306,+ 'numberNative' => false,+ ];+ public array $test2 = [+ 'DSN' => '',+ 'hostname' => 'localhost',+ 'username' => 'root',+ 'password' => '',+ 'database' => 'ci4_test2',+ 'DBDriver' => 'MySQLi',+ 'DBPrefix' => '',+ 'pConnect' => false,+ 'DBDebug' => true,+ 'charset' => 'utf8',+ 'DBCollat' => 'utf8_general_ci',+ 'swapPre' => '',+ 'encrypt' => false,+ 'compress' => false,+ 'strictOn' => false,+ 'failover' => [],+ 'port' => 3306,+ 'numberNative' => false,+ ];+
/**
* This database connection is used when
* running PHPUnit database tests.
<?phpnamespaceApp\Database\Migrations;
useCodeIgniter\Database\Migration;
class AddBlog extends Migration
{
protected$DBGroup = 'test1';
publicfunctionup()
{
$this->forge->addField([
'blog_id' => [
'type' => 'INT',
'constraint' => 5,
'unsigned' => true,
'auto_increment' => true,
],
'blog_title' => [
'type' => 'VARCHAR',
'constraint' => '100',
],
'blog_description' => [
'type' => 'TEXT',
'null' => true,
],
]);
$this->forge->addKey('blog_id', true);
$this->forge->createTable('blog');
}
publicfunctiondown()
{
$this->forge->dropTable('blog');
}
}$ php spark migrateCodeIgniter v4.4.0 Command Line Tool - Server Time: 2023-09-04 02:12:42 UTC+00:00Running all new migrations... Running: (App) 2023-09-04-013453_App\Database\Migrations\AddBlogMigrations complete.
$ php spark migrate:statusCodeIgniter v4.4.0 Command Line Tool - Server Time: 2023-09-04 02:15:26 UTC+00:00+-----------+-------------------+----------+-------+---------------------+-------+| Namespace | Version | Filename | Group | Migrated On | Batch |+-----------+-------------------+----------+-------+---------------------+-------+| App | 2023-09-04-013453 | AddBlog | test1 | 2023-09-04 02:12:42 | 1 |+-----------+-------------------+----------+-------+---------------------+-------+
References
Migration of non-default group is also executed without the
-goption.How to Reproduce
References
spark migrateissue with -g option #7846