diff options
author | Nick Thomas <nick@gitlab.com> | 2016-12-14 22:58:44 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2016-12-15 13:57:03 +0000 |
commit | 35a3e9183052bab847c30203f27fea9cf77901a4 (patch) | |
tree | d49734bb5f147c457c958c7bdb17cecc6a4cc156 /db/migrate/20161207231621_create_environment_name_unique_index.rb | |
parent | 2d1dfae9b63d35232e4bf537a0aca9b95e2d5e72 (diff) | |
download | gitlab-ce-35a3e9183052bab847c30203f27fea9cf77901a4.tar.gz |
Make the index on environment name and project id unique, fixing up any duplicates
Diffstat (limited to 'db/migrate/20161207231621_create_environment_name_unique_index.rb')
-rw-r--r-- | db/migrate/20161207231621_create_environment_name_unique_index.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/db/migrate/20161207231621_create_environment_name_unique_index.rb b/db/migrate/20161207231621_create_environment_name_unique_index.rb new file mode 100644 index 00000000000..ac680c8d10f --- /dev/null +++ b/db/migrate/20161207231621_create_environment_name_unique_index.rb @@ -0,0 +1,18 @@ +class CreateEnvironmentNameUniqueIndex < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + DOWNTIME = true + DOWNTIME_REASON = 'Making a non-unique index into a unique index' + + def up + remove_index :environments, [:project_id, :name] + add_concurrent_index :environments, [:project_id, :name], unique: true + end + + def down + remove_index :environments, [:project_id, :name], unique: true + add_concurrent_index :environments, [:project_id, :name] + end +end |