Skip to content

Commit

Permalink
Merge pull request #17 from Flowpack/albe-safe-create-index
Browse files Browse the repository at this point in the history
BUGFIX: Make it safe to run setup more than once
  • Loading branch information
daniellienert authored Feb 26, 2020
2 parents ab2c68a + eb94271 commit 2624e53
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Classes/Queue/DoctrineQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ public function setUp(): void
$createDatabaseStatement = "CREATE TABLE IF NOT EXISTS {$this->connection->quoteIdentifier($this->tableName)} (id INTEGER PRIMARY KEY AUTO_INCREMENT, payload LONGTEXT NOT NULL, state VARCHAR(255) NOT NULL, failures INTEGER NOT NULL DEFAULT 0, scheduled DATETIME DEFAULT NULL) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB";
}
$this->connection->exec($createDatabaseStatement);
$this->connection->exec("CREATE INDEX state_scheduled ON {$this->connection->quoteIdentifier($this->tableName)} (state, scheduled)");
try {
$this->connection->exec("CREATE INDEX state_scheduled ON {$this->connection->quoteIdentifier($this->tableName)} (state, scheduled)");
} catch (Exception $e) {
// See https://dba.stackexchange.com/questions/24531/mysql-create-index-if-not-exists
}
}

/**
Expand Down

0 comments on commit 2624e53

Please sign in to comment.