Skip to content

Commit eb94271

Browse files
authored
BUGFIX: Make it safe to run setup more than once
Fixes #12
1 parent ab2c68a commit eb94271

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Classes/Queue/DoctrineQueue.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ public function setUp(): void
114114
$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";
115115
}
116116
$this->connection->exec($createDatabaseStatement);
117-
$this->connection->exec("CREATE INDEX state_scheduled ON {$this->connection->quoteIdentifier($this->tableName)} (state, scheduled)");
117+
try {
118+
$this->connection->exec("CREATE INDEX state_scheduled ON {$this->connection->quoteIdentifier($this->tableName)} (state, scheduled)");
119+
} catch (Exception $e) {
120+
// See https://dba.stackexchange.com/questions/24531/mysql-create-index-if-not-exists
121+
}
118122
}
119123

120124
/**

0 commit comments

Comments
 (0)