diff options
author | Alejandro RodrÃguez <alejorro70@gmail.com> | 2016-10-20 22:59:01 -0300 |
---|---|---|
committer | Alejandro RodrÃguez <alejorro70@gmail.com> | 2016-10-20 22:59:01 -0300 |
commit | eebc3ba3db8c5ff6853de2b3068374394c865567 (patch) | |
tree | 9bea68ff8fbee08e8345b8cba48d941701b1ac88 | |
parent | b7170277c65fb76b5d0d732ab598eb475b0d823c (diff) | |
download | gitlab-ce-23609-adduniqueindextolabels-fails-when-there-are-no-duplicated-ids.tar.gz |
Fix AddUniqueIndexToLabels migration to skip unnecesary queries23609-adduniqueindextolabels-fails-when-there-are-no-duplicated-ids
-rw-r--r-- | db/migrate/20161017125927_add_unique_index_to_labels.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/db/migrate/20161017125927_add_unique_index_to_labels.rb b/db/migrate/20161017125927_add_unique_index_to_labels.rb index 16ae38612de..361c9bbd566 100644 --- a/db/migrate/20161017125927_add_unique_index_to_labels.rb +++ b/db/migrate/20161017125927_add_unique_index_to_labels.rb @@ -13,6 +13,8 @@ class AddUniqueIndexToLabels < ActiveRecord::Migration label_id = duplicated_ids.first duplicated_ids.delete(label_id) + next if duplicated_ids.empty? + execute("UPDATE label_links SET label_id = #{label_id} WHERE label_id IN(#{duplicated_ids.join(",")})") execute("DELETE FROM labels WHERE id IN(#{duplicated_ids.join(",")})") end |