Skip to content

Commit cdd3b2d

Browse files
dereuromarkclaude
andcommitted
Add support for unified cake_migrations table
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 <[email protected]>
1 parent cb2221a commit cdd3b2d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

config/Migrations/20240307154751_MigrationQueueInitV8.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,22 @@ class MigrationQueueInitV8 extends BaseMigration {
1414
public function up(): void {
1515
// We expect all v7 migrations to be run before this migration (including 20231112807150_MigrationAddIndex)
1616
$version = '20240307154751';
17-
if (ConnectionManager::getConfig('default')['driver'] === 'Cake\Database\Driver\Sqlserver') {
18-
$this->execute('DELETE FROM queue_phinxlog WHERE [version] < \'' . $version . '\'');
17+
$useUnifiedTable = $this->hasTable('cake_migrations');
18+
19+
if ($useUnifiedTable) {
20+
// Unified cake_migrations table (Migrations plugin 5.x) uses plugin column
21+
if (ConnectionManager::getConfig('default')['driver'] === 'Cake\Database\Driver\Sqlserver') {
22+
$this->execute('DELETE FROM cake_migrations WHERE [plugin] = \'Queue\' AND [version] < \'' . $version . '\'');
23+
} else {
24+
$this->execute('DELETE FROM cake_migrations WHERE plugin = \'Queue\' AND version < \'' . $version . '\'');
25+
}
1926
} else {
20-
$this->execute('DELETE FROM queue_phinxlog WHERE version < \'' . $version . '\'');
27+
// Legacy phinxlog table (Migrations plugin 4.x and earlier)
28+
if (ConnectionManager::getConfig('default')['driver'] === 'Cake\Database\Driver\Sqlserver') {
29+
$this->execute('DELETE FROM queue_phinxlog WHERE [version] < \'' . $version . '\'');
30+
} else {
31+
$this->execute('DELETE FROM queue_phinxlog WHERE version < \'' . $version . '\'');
32+
}
2133
}
2234

2335
if ($this->hasTable('queued_jobs')) {

0 commit comments

Comments
 (0)