Avoid double index creation

This commit is contained in:
Lucas Bartholemy 2020-07-29 10:11:14 +02:00
parent 23a6abcb2c
commit 56d276a9fa
2 changed files with 8 additions and 2 deletions

View File

@ -12,7 +12,8 @@ class m200715_184207_commentIndex extends Migration
*/
public function safeUp()
{
$this->createIndex('idx_comment_target', 'comment', ['object_model', 'object_id'], false);
// Was only used in beta version, avoid double index creation in stable version update
//$this->createIndex('idx_comment_target', 'comment', ['object_model', 'object_id'], false);
}
/**

View File

@ -12,7 +12,12 @@ class m200729_080349_commentIndex_fix_order extends Migration
*/
public function safeUp()
{
$this->dropIndex('idx_comment_target', 'comment');
try {
$this->dropIndex('idx_comment_target', 'comment');
} catch (\Exception $ex) {
// May not exist, see migration m200715_184207_commentIndex
}
$this->createIndex('idx_comment_target', 'comment', ['object_id', 'object_model'], false);
}