-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
databaseIssues or pull requests that affect the database layerIssues or pull requests that affect the database layerquestion
Description
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.<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddBlog extends Migration
{
protected $DBGroup = 'test1';
public function up()
{
$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');
}
public function down()
{
$this->forge->dropTable('blog');
}
}$ php spark migrate
CodeIgniter v4.4.0 Command Line Tool - Server Time: 2023-09-04 02:12:42 UTC+00:00
Running all new migrations...
Running: (App) 2023-09-04-013453_App\Database\Migrations\AddBlog
Migrations complete.$ php spark migrate:status
CodeIgniter 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
Metadata
Metadata
Assignees
Labels
databaseIssues or pull requests that affect the database layerIssues or pull requests that affect the database layerquestion