diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2018-08-22 19:55:46 +0300 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2018-08-22 19:55:46 +0300 |
commit | 6462f094daeb6a6bc43bb478d5d9d0bfb30bebf8 (patch) | |
tree | a2ec4746796b8012d8da8dca455fb815400674f5 | |
parent | 1231d788471287eecd9590a851e93b39ce8135a6 (diff) |
Fix migration for mysql.ab-api-protected-tags
-rw-r--r-- | db/migrate/20180711103851_drop_duplicate_protected_tags.rb | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/db/migrate/20180711103851_drop_duplicate_protected_tags.rb b/db/migrate/20180711103851_drop_duplicate_protected_tags.rb index fd87ba0d86e..8fa2137551e 100644 --- a/db/migrate/20180711103851_drop_duplicate_protected_tags.rb +++ b/db/migrate/20180711103851_drop_duplicate_protected_tags.rb @@ -25,17 +25,15 @@ class DropDuplicateProtectedTags < ActiveRecord::Migration .group(:name, :project_id) .select('max(id)') + tags = ProtectedTag + .where(project_id: projects) + .where.not(id: ids) + if Gitlab::Database.postgresql? - ProtectedTag - .where(project_id: projects) - .where.not(id: ids) - .delete_all + tags.delete_all else - sql = ProtectedTag - .select(:id) - .where(project_id: projects) - .where.not(id: ids) - .to_sql + # Workaround needed for MySQL + sql = "SELECT id FROM (#{tags.to_sql}) protected_tags" ProtectedTag.where("id IN (#{sql})").delete_all # rubocop:disable GitlabSecurity/SqlInjection end |