Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions config/Migrations/20240307154751_MigrationQueueInitV8.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down