Skip to content

Commit

Permalink
Make sure this works for mssql. (#408)
Browse files Browse the repository at this point in the history
* Make sure this works for mssql.

* Make sure this works for mssql.
  • Loading branch information
dereuromark committed Mar 5, 2024
1 parent ea037ff commit c56f4f6
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions config/Migrations/20231112807150_MigrationAddIndex.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Cake\Datasource\ConnectionManager;
use Phinx\Migration\AbstractMigration;

class MigrationAddIndex extends AbstractMigration {
Expand All @@ -9,11 +10,21 @@ class MigrationAddIndex extends AbstractMigration {
*/
public function change() {
// Shim: make sure this is void when a migrating with `202311128071500` instead of `20231112807150` has been run already.
$result = $this->query('SELECT * FROM queue_phinxlog WHERE version = \'202311128071500\' LIMIT 1')->fetch();
if ($result) {
$this->execute('DELETE FROM queue_phinxlog WHERE version = \'202311128071500\' LIMIT 1');
$version = '202311128071500';
if (ConnectionManager::getConfig('default')['driver'] === 'Cake\Database\Driver\Sqlserver') {
$result = $this->query('SELECT TOP(1) * FROM queue_phinxlog WHERE version = \'' . $version . '\'')->fetch();
if ($result) {
$this->execute('DELETE TOP(1) FROM queue_phinxlog WHERE version = \'' . $version . '\'');

return;
return;
}
} else {
$result = $this->query('SELECT * FROM queue_phinxlog WHERE version = \'' . $version . '\' LIMIT 1')->fetch();
if ($result) {
$this->execute('DELETE FROM queue_phinxlog WHERE version = \'' . $version . '\' LIMIT 1');

return;
}
}

$table = $this->table('queued_jobs');
Expand Down

0 comments on commit c56f4f6

Please sign in to comment.