merge prod to main
This commit is contained in:
Regular → Executable
+22
-3
@@ -13,11 +13,11 @@ class AllowCompetitionWinnerRankTies extends Migration
|
||||
return;
|
||||
}
|
||||
|
||||
if ($db->indexExists('competition_winners', 'competition_id_class_section_id_rank')) {
|
||||
if ($this->indexExists($db, 'competition_winners', 'competition_id_class_section_id_rank')) {
|
||||
$db->query('DROP INDEX competition_id_class_section_id_rank ON competition_winners');
|
||||
}
|
||||
|
||||
if (!$db->indexExists('competition_winners', 'competition_id_class_section_id_rank')) {
|
||||
if (! $this->indexExists($db, 'competition_winners', 'competition_id_class_section_id_rank')) {
|
||||
$db->query(
|
||||
'CREATE INDEX competition_id_class_section_id_rank ON competition_winners (competition_id, class_section_id, rank)'
|
||||
);
|
||||
@@ -31,7 +31,7 @@ class AllowCompetitionWinnerRankTies extends Migration
|
||||
return;
|
||||
}
|
||||
|
||||
if ($db->indexExists('competition_winners', 'competition_id_class_section_id_rank')) {
|
||||
if ($this->indexExists($db, 'competition_winners', 'competition_id_class_section_id_rank')) {
|
||||
$db->query('DROP INDEX competition_id_class_section_id_rank ON competition_winners');
|
||||
}
|
||||
|
||||
@@ -39,4 +39,23 @@ class AllowCompetitionWinnerRankTies extends Migration
|
||||
'ALTER TABLE competition_winners ADD UNIQUE KEY competition_id_class_section_id_rank (competition_id, class_section_id, rank)'
|
||||
);
|
||||
}
|
||||
|
||||
private function indexExists($db, string $table, string $index): bool
|
||||
{
|
||||
if (method_exists($db, 'indexExists')) {
|
||||
return $db->indexExists($table, $index);
|
||||
}
|
||||
|
||||
$dbName = $db->getDatabase();
|
||||
$builder = $db->table('information_schema.STATISTICS');
|
||||
$row = $builder
|
||||
->select('INDEX_NAME')
|
||||
->where('TABLE_SCHEMA', $dbName)
|
||||
->where('TABLE_NAME', $table)
|
||||
->where('INDEX_NAME', $index)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
return ! empty($row);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user