From 73ae365602a2da38ef165943f3a941d51d345ae1 Mon Sep 17 00:00:00 2001 From: Nicos Panayides Date: Wed, 18 Feb 2026 16:54:29 +0200 Subject: [PATCH 1/9] Avoid false which is mangled by PDO --- src/Command/UpgradeCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Command/UpgradeCommand.php b/src/Command/UpgradeCommand.php index 1d766da2..a608674a 100644 --- a/src/Command/UpgradeCommand.php +++ b/src/Command/UpgradeCommand.php @@ -282,7 +282,7 @@ protected function migrateTable( 'plugin' => $plugin, 'start_time' => $row['start_time'] ?? null, 'end_time' => $row['end_time'] ?? null, - 'breakpoint' => $row['breakpoint'] ?? 0, + 'breakpoint' => $row['breakpoint'] === false ? 0 : $row['breakpoint'] ?? 0, ]); $insertQuery->execute(); } catch (QueryException $e) { From 77191b8de75f0a44398151e1b8c4daedcf01b492 Mon Sep 17 00:00:00 2001 From: Nicos Panayides Date: Thu, 19 Feb 2026 10:46:19 +0200 Subject: [PATCH 2/9] Always pass an integer for the breakpoint as suggested by dereuromark --- src/Command/UpgradeCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Command/UpgradeCommand.php b/src/Command/UpgradeCommand.php index a608674a..5897c458 100644 --- a/src/Command/UpgradeCommand.php +++ b/src/Command/UpgradeCommand.php @@ -282,7 +282,7 @@ protected function migrateTable( 'plugin' => $plugin, 'start_time' => $row['start_time'] ?? null, 'end_time' => $row['end_time'] ?? null, - 'breakpoint' => $row['breakpoint'] === false ? 0 : $row['breakpoint'] ?? 0, + 'breakpoint' => (int)($row['breakpoint'] ?? 0), ]); $insertQuery->execute(); } catch (QueryException $e) { From dc3bf52f63ac8a1bae5fbbd70a5b611ed1cb8638 Mon Sep 17 00:00:00 2001 From: Nicos Panayides Date: Thu, 19 Feb 2026 11:15:18 +0200 Subject: [PATCH 3/9] Added test case with an actual migration to ensure we correctly insert the migrations into the unified table. --- tests/TestCase/Command/UpgradeCommandTest.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/TestCase/Command/UpgradeCommandTest.php b/tests/TestCase/Command/UpgradeCommandTest.php index 0fe13271..f36509ec 100644 --- a/tests/TestCase/Command/UpgradeCommandTest.php +++ b/tests/TestCase/Command/UpgradeCommandTest.php @@ -9,6 +9,7 @@ use Migrations\Db\Adapter\AdapterInterface; use Migrations\Migration\Environment; use Migrations\Test\TestCase\TestCase; +use PDO; class UpgradeCommandTest extends TestCase { @@ -118,4 +119,40 @@ public function testExecuteSimpleExecuteDropTables(): void $this->assertTrue($adapter->hasTable('cake_migrations')); $this->assertFalse($adapter->hasTable('phinxlog')); } + + public function testExecuteWithMigrations(): void + { + Configure::write('Migrations.legacyTables', true); + try { + $this->getAdapter()->createSchemaTable(); + } catch (Exception $e) { + // Table probably exists + } + + $this->getAdapter()->getInsertBuilder() + ->insert(['version', 'migration_name', 'breakpoint']) + ->into('phinxlog') + ->values(['20250118143003', 'TestMigration', 0]) + ->execute(); + + $this->exec('migrations upgrade -c test'); + $this->assertExitSuccess(); + // Check for status output + $this->assertOutputContains('Creating unified table'); + $this->assertOutputContains('Total records migrated: 1'); + + // Validate record in the unified table + $this->assertTrue($this->getAdapter()->hasTable('cake_migrations')); + + $rows = $this->getAdapter()->getSelectBuilder() + ->select(['version', 'migration_name', 'breakpoint']) + ->from('cake_migrations') + ->where([ + 'migration_name' => 'TestMigration' + ]) + ->all() + ->fetchAll(PDO::FETCH_ASSOC); + + $this->assertCount(1, $rows); + } } From 8ac1f25cd12607d69ad590be3c098d0df55b5eed Mon Sep 17 00:00:00 2001 From: Nicos Panayides Date: Thu, 19 Feb 2026 11:41:53 +0200 Subject: [PATCH 4/9] Fix insert --- tests/TestCase/Command/UpgradeCommandTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/TestCase/Command/UpgradeCommandTest.php b/tests/TestCase/Command/UpgradeCommandTest.php index f36509ec..079e3b22 100644 --- a/tests/TestCase/Command/UpgradeCommandTest.php +++ b/tests/TestCase/Command/UpgradeCommandTest.php @@ -132,7 +132,11 @@ public function testExecuteWithMigrations(): void $this->getAdapter()->getInsertBuilder() ->insert(['version', 'migration_name', 'breakpoint']) ->into('phinxlog') - ->values(['20250118143003', 'TestMigration', 0]) + ->values([ + 'version' => '20250118143003', + 'migration_name' => 'TestMigration', + 'breakpoint' => 0, + ]) ->execute(); $this->exec('migrations upgrade -c test'); From 7a025dd0de29aba8f6feecff7c268d2154206983 Mon Sep 17 00:00:00 2001 From: Nicos Panayides Date: Thu, 19 Feb 2026 11:49:11 +0200 Subject: [PATCH 5/9] Fix assertion for the output --- tests/TestCase/Command/UpgradeCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TestCase/Command/UpgradeCommandTest.php b/tests/TestCase/Command/UpgradeCommandTest.php index 079e3b22..8545b5a2 100644 --- a/tests/TestCase/Command/UpgradeCommandTest.php +++ b/tests/TestCase/Command/UpgradeCommandTest.php @@ -143,7 +143,7 @@ public function testExecuteWithMigrations(): void $this->assertExitSuccess(); // Check for status output $this->assertOutputContains('Creating unified table'); - $this->assertOutputContains('Total records migrated: 1'); + $this->assertOutputContains('Total records migrated'); // Validate record in the unified table $this->assertTrue($this->getAdapter()->hasTable('cake_migrations')); From a7e5a55462a7b517645726eb4f4ffc7c1b85cde8 Mon Sep 17 00:00:00 2001 From: Nicos Panayides Date: Thu, 19 Feb 2026 11:50:14 +0200 Subject: [PATCH 6/9] phpcs fix --- tests/TestCase/Command/UpgradeCommandTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/TestCase/Command/UpgradeCommandTest.php b/tests/TestCase/Command/UpgradeCommandTest.php index 8545b5a2..508bb313 100644 --- a/tests/TestCase/Command/UpgradeCommandTest.php +++ b/tests/TestCase/Command/UpgradeCommandTest.php @@ -151,9 +151,7 @@ public function testExecuteWithMigrations(): void $rows = $this->getAdapter()->getSelectBuilder() ->select(['version', 'migration_name', 'breakpoint']) ->from('cake_migrations') - ->where([ - 'migration_name' => 'TestMigration' - ]) + ->where(['migration_name' => 'TestMigration']) ->all() ->fetchAll(PDO::FETCH_ASSOC); From 47acd92ee6d1ff888f778680b8e5f9d7ccba2cf1 Mon Sep 17 00:00:00 2001 From: Nicos Panayides Date: Thu, 19 Feb 2026 11:51:39 +0200 Subject: [PATCH 7/9] Fix fetching migrations in test --- tests/TestCase/Command/UpgradeCommandTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/TestCase/Command/UpgradeCommandTest.php b/tests/TestCase/Command/UpgradeCommandTest.php index 508bb313..90008439 100644 --- a/tests/TestCase/Command/UpgradeCommandTest.php +++ b/tests/TestCase/Command/UpgradeCommandTest.php @@ -152,8 +152,7 @@ public function testExecuteWithMigrations(): void ->select(['version', 'migration_name', 'breakpoint']) ->from('cake_migrations') ->where(['migration_name' => 'TestMigration']) - ->all() - ->fetchAll(PDO::FETCH_ASSOC); + ->all(); $this->assertCount(1, $rows); } From 48311a4893df7a77374f4ae6bcc9a808df16b40f Mon Sep 17 00:00:00 2001 From: Nicos Panayides Date: Thu, 19 Feb 2026 12:05:58 +0200 Subject: [PATCH 8/9] Clean up after upgrade tests to avoid breaking other tests --- tests/TestCase/Command/UpgradeCommandTest.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/TestCase/Command/UpgradeCommandTest.php b/tests/TestCase/Command/UpgradeCommandTest.php index 90008439..ceddd953 100644 --- a/tests/TestCase/Command/UpgradeCommandTest.php +++ b/tests/TestCase/Command/UpgradeCommandTest.php @@ -9,7 +9,6 @@ use Migrations\Db\Adapter\AdapterInterface; use Migrations\Migration\Environment; use Migrations\Test\TestCase\TestCase; -use PDO; class UpgradeCommandTest extends TestCase { @@ -24,6 +23,17 @@ public function setUp(): void $connection->execute('DROP TABLE IF EXISTS cake_migrations'); } + public function tearDown(): void + { + $this->clearMigrationRecords('test'); + + /** @var \Cake\Database\Connection $connection */ + $connection = ConnectionManager::get('test'); + $connection->execute('DROP TABLE IF EXISTS cake_migrations'); + + parent::tearDown(); + } + protected function getAdapter(): AdapterInterface { $config = ConnectionManager::getConfig('test'); From 4b89ed7aa5600a8a485f1e13adab45c870a70a02 Mon Sep 17 00:00:00 2001 From: Nicos Panayides Date: Fri, 20 Feb 2026 16:50:31 +0200 Subject: [PATCH 9/9] Fix ci pipeline for mariadb --- .github/workflows/ci.yml | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a800224..50cbc1d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,18 +59,29 @@ jobs: persist-credentials: false - name: Setup MariaDB - uses: getong/mariadb-action@v1.11 - if: matrix.db-type == 'mariadb' - with: - mariadb version: '10.11.10' - mysql database: 'cakephp_test' - mysql root password: 'root' - - name: Setup MariaDB (part 2) if: matrix.db-type == 'mariadb' run: | - mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp_comparisons;' - mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp_snapshot;' - + docker run -d --name=mariadb \ + -e MARIADB_ROOT_PASSWORD=root \ + -e MARIADB_DATABASE=cakephp_test \ + -p 3306:3306 \ + --health-cmd="mariadb-admin ping -h 127.0.0.1 -proot || exit 1" \ + --health-interval=10s \ + --health-timeout=5s \ + --health-retries=10 \ + mariadb:11.8 + + echo "Waiting for MariaDB to be ready..." + for i in {1..60}; do + if docker exec mariadb mariadb-admin ping -h 127.0.0.1 -proot >/dev/null 2>&1; then + echo "MariaDB is responding." + break + fi + + sleep 2 + done + mariadb -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp_comparisons;' + mariadb -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp_snapshot;' - name: Setup MySQL if: matrix.db-type == 'mysql' run: |