-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
PHP Version
8.2
CodeIgniter4 Version
4.4.1
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
MySQL 8
What happened?
Currently my project has two database groups, "default" and "test", I am currently developing and using the "test" database, and I configure in my .env file the following:
#--------------------------------------------------------------------
# ENVIRONMENT
#--------------------------------------------------------------------
CI_ENVIRONMENT = development
...
#--------------------------------------------------------------------
# DATABASE
#--------------------------------------------------------------------
database.defaultGroup = tests
database.tests.hostname = localhost
database.tests.database = macc_tests
database.tests.username = root
database.tests.password =
database.tests.DBDriver = MySQLi
database.tests.DBPrefix =
database.tests.charset = utf8mb4
database.tests.DBCollat = utf8mb4_general_ci
database.tests.port = 3306Now when I run migration from command I have to do it like this:
php spark migrate -g test
The process runs normally, the problem is when I rollback, because when I run
php spark migrate:rollback -g tests
Since it does not make any changes, it does not delete or modify the tables
Steps to Reproduce
In .env:
#--------------------------------------------------------------------
# ENVIRONMENT
#--------------------------------------------------------------------
CI_ENVIRONMENT = development
...
#--------------------------------------------------------------------
# DATABASE
#--------------------------------------------------------------------
database.defaultGroup = tests
database.tests.hostname = localhost
database.tests.database = macc_tests
database.tests.username = root
database.tests.password =
database.tests.DBDriver = MySQLi
database.tests.DBPrefix =
database.tests.charset = utf8mb4
database.tests.DBCollat = utf8mb4_general_ci
database.tests.port = 3306in app\Database\Migrations\2023-10-09-190224_TipoUsuarioMigration.php, for all "Migration" files I don't add "DBGroup" property:
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class TipoUsuarioMigration extends Migration
{
// protected $DBGroup = 'default';
public function up()
{
$this->forge
->addField(
[
'id' => [
'type' => 'INT',
'auto_increment' => true,
],
'nombre' => [
'type' => 'VARCHAR',
'constraint' => 50,
],
]
)
->addPrimaryKey('id')
->createTable('tipo_usuario', true);
}
public function down()
{
$this->forge->dropTable('tipo_usuario', true);
}
}In CLI:
php spark migrate -g testsphp spark migrate:rollback -g tests<--- doesn't work, doesn't delete the table.
Expected Output
when you run the command php spark migrate:rollback -g tests, it should modify or delete tables.
Anything else?
When I change the CI_ENVIRONMENT variable in .env like this CI_ENVIRONMENT = testing, the rollback works correctly.