diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-06-16 12:53:32 +0200 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-06-20 13:29:04 +0200 |
commit | ca01c4c6484aa135234028e5e1ca5829adad1a50 (patch) | |
tree | c8033b1de6db640c7fab80d2a8f7a800a9d943d8 /db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb | |
parent | 98cede7ebeae9dac994b35b66be6aab14eb932b3 (diff) | |
download | gitlab-ce-ca01c4c6484aa135234028e5e1ca5829adad1a50.tar.gz |
Remove Duplicated keys add UNIQUE index to fingerprint18697-uniqueness-key-validation
Diffstat (limited to 'db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb')
-rw-r--r-- | db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb b/db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb new file mode 100644 index 00000000000..4bb4204cebd --- /dev/null +++ b/db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb @@ -0,0 +1,21 @@ +class RemoveKeysFingerprintIndexIfExists < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + # https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/250 + # That MR was added on gitlab-ee so we need to check if the index + # already exists because we want to do is create an unique index instead. + + def up + if index_exists?(:keys, :fingerprint) + remove_index :keys, :fingerprint + end + end + + def down + unless index_exists?(:keys, :fingerprint) + add_concurrent_index :keys, :fingerprint + end + end +end |