This is a (multiple allowed):
bug
CakePHP Version: 4.4.6
Migrations plugin version: 3.6.0
Database server (MySQL, SQLite, Postgres): MySQL 8.0.29
PHP Version: 8.1.14
Platform / OS: Linux
What you did
define migrations of the application (create users) and the TestPlugin plugin (create test_plugin_entities).
put in tests/bootstrap.php:
(new Migrator ())->runMany ([
['skip ' => ['test_plugin_entities ' ]],
['plugin ' => 'TestPlugin ' , 'skip ' => ['[!t]* ' , 't[!e]* ' ]],
]);
run tests.
add an application migration.
run tests.
run tests.
run tests.
Expected Behavior
All runs succeed.
On second run,
application tables are dropped and re-created by migrations.
TestPlugin tables are not dropped.
On third and forth runs, no tables are dropped.
Actual Behavior
Second run failed:
Error in bootstrap script: PDOException:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'test_plugin_entities' already exists
application tables are dropped and re-created by migrations.
TestPlugin tables are not dropped, but test_plugin_phinxlog is empty.
Third run failed:
Error in bootstrap script: PDOException:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists
application tables are not dropped, but phinxlog is empty.
Forth run succeeded.
application tables are dropped and re-created by migrations.
TestPlugin tables are dropped and re-created by migrations.
Cause
$ phinxTables = $ this ->getPhinxTables ($ connection );
if (count ($ phinxTables )) {
$ this ->helper ->truncateTables ($ connection , $ phinxTables );
}
This truncates phinxlog of unrelated migration sets.
Workaround
This problem doesn't occur if we don't use the skip option, but tables are truncated twice in one run.
This is a (multiple allowed):
bug
CakePHP Version: 4.4.6
Migrations plugin version: 3.6.0
Database server (MySQL, SQLite, Postgres): MySQL 8.0.29
PHP Version: 8.1.14
Platform / OS: Linux
What you did
users) and theTestPluginplugin (createtest_plugin_entities).tests/bootstrap.php:Expected Behavior
All runs succeed.
On second run,
TestPlugintables are not dropped.On third and forth runs, no tables are dropped.
Actual Behavior
Second run failed:
TestPlugintables are not dropped, buttest_plugin_phinxlogis empty.Third run failed:
phinxlogis empty.Forth run succeeded.
TestPlugintables are dropped and re-created by migrations.Cause
migrations/src/TestSuite/Migrator.php
Lines 217 to 220 in 792cc07
This truncates
phinxlogof unrelated migration sets.Workaround
This problem doesn't occur if we don't use the
skipoption, but tables are truncated twice in one run.