From cdd3b2d60d8dc1716c77ff8099686d3705f23db3 Mon Sep 17 00:00:00 2001 From: mscherer Date: Mon, 24 Nov 2025 00:45:48 +0100 Subject: [PATCH] Add support for unified cake_migrations table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support both the legacy queue_phinxlog table (Migrations plugin 4.x) and the new cake_migrations table (Migrations plugin 5.x). The migration now checks if cake_migrations exists and uses it with the plugin column filter, otherwise falls back to queue_phinxlog. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../20240307154751_MigrationQueueInitV8.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/config/Migrations/20240307154751_MigrationQueueInitV8.php b/config/Migrations/20240307154751_MigrationQueueInitV8.php index fb49e7d6..85e28cac 100644 --- a/config/Migrations/20240307154751_MigrationQueueInitV8.php +++ b/config/Migrations/20240307154751_MigrationQueueInitV8.php @@ -14,10 +14,22 @@ class MigrationQueueInitV8 extends BaseMigration { public function up(): void { // We expect all v7 migrations to be run before this migration (including 20231112807150_MigrationAddIndex) $version = '20240307154751'; - if (ConnectionManager::getConfig('default')['driver'] === 'Cake\Database\Driver\Sqlserver') { - $this->execute('DELETE FROM queue_phinxlog WHERE [version] < \'' . $version . '\''); + $useUnifiedTable = $this->hasTable('cake_migrations'); + + if ($useUnifiedTable) { + // Unified cake_migrations table (Migrations plugin 5.x) uses plugin column + if (ConnectionManager::getConfig('default')['driver'] === 'Cake\Database\Driver\Sqlserver') { + $this->execute('DELETE FROM cake_migrations WHERE [plugin] = \'Queue\' AND [version] < \'' . $version . '\''); + } else { + $this->execute('DELETE FROM cake_migrations WHERE plugin = \'Queue\' AND version < \'' . $version . '\''); + } } else { - $this->execute('DELETE FROM queue_phinxlog WHERE version < \'' . $version . '\''); + // Legacy phinxlog table (Migrations plugin 4.x and earlier) + if (ConnectionManager::getConfig('default')['driver'] === 'Cake\Database\Driver\Sqlserver') { + $this->execute('DELETE FROM queue_phinxlog WHERE [version] < \'' . $version . '\''); + } else { + $this->execute('DELETE FROM queue_phinxlog WHERE version < \'' . $version . '\''); + } } if ($this->hasTable('queued_jobs')) {