-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migration:rollback does not work in 'development' environment #8026
Comments
Please see: #7894 |
Hello, I have reviewed the code of the file system\Database\MigrationRunner.php and I came across the following code starting from lines 849 -855 if (ENVIRONMENT !== 'testing' && $group === 'tests' && $this->groupFilter !== 'tests') {
// @codeCoverageIgnoreStart
$this->groupSkip = true;
return true;
// @codeCoverageIgnoreEnd
} I have commented on these lines and it has solved the problem, I hope they make the decision to integrate the -g option into the rollback again, and eliminate the mentioned lines. It should be allowed that regardless of whether your CI_ENVIRONMENT is "production", "testing" or "development" you can rollback without any problem. |
The migration you expect and the one provided by CI behave differently. CI's migration is kind of version control system for database state, and it manages the state of multiple databases as a whole. For example, when migrations are executed as follows,
If we roll back only db_b, only the following tables will remain, but the entire database has never been in this state. This is an inconsistent state that has never existed.
If the tables in each database were completely independent, there might be no problem with the above state. |
@xonipatino Please change the group name CodeIgniter4/app/Config/Database.php Lines 49 to 52 in 815b802
|
Please do not use
|
Hola
Hello @kenjis, thank you for your answer, I thought that the "tests" group could be used without a problem, but since you clarified it, then I will create a new group in app\config\Database.php with the same "Default" options and then from the " .env" I modify it to my needs. thanks you. |
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:
Now 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:
in app\Database\Migrations\2023-10-09-190224_TipoUsuarioMigration.php, for all "Migration" files I don't add "DBGroup" property:
In CLI:
php spark migrate -g tests
php 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.The text was updated successfully, but these errors were encountered: