diff --git a/db/migrations/20220401_add_index_to_cw_user_progresses_v50.php b/db/migrations/20220401_add_index_to_cw_user_progresses_v50.php index aaea146ee723042e9b9bf965286b9afee1942e73..fe86201d8d7be964de17e6897c92e860ccaa8a1e 100644 --- a/db/migrations/20220401_add_index_to_cw_user_progresses_v50.php +++ b/db/migrations/20220401_add_index_to_cw_user_progresses_v50.php @@ -8,6 +8,14 @@ final class AddIndexToCwUserProgressesV50 extends Migration public function up() { + // avoid running this migration twice + $query = "SHOW INDEX FROM `cw_user_progresses` WHERE Key_name = 'block_id'"; + $result = DBManager::get()->query($query); + + if ($result && $result->rowCount() > 0) { + return; + } + $query = "ALTER TABLE `cw_user_progresses` ADD INDEX `block_id` (`block_id`)"; DBManager::get()->exec($query);