diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-01-25 12:55:11 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-01-25 12:55:11 +0100 |
commit | b97b4d258552cadc55f408a28569c4a0d34b38a3 (patch) | |
tree | ecd13a773dd2aa23bdf221b6e421829d52122015 /db | |
parent | ce71b1ce072b024802e7e4ff07486e253c24d964 (diff) | |
download | gitlab-ce-b97b4d258552cadc55f408a28569c4a0d34b38a3.tar.gz |
Add an unique index on pipeline stage name
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20180125111139_add_unique_pipeline_stage_name_index.rb | 17 | ||||
-rw-r--r-- | db/schema.rb | 5 |
2 files changed, 20 insertions, 2 deletions
diff --git a/db/post_migrate/20180125111139_add_unique_pipeline_stage_name_index.rb b/db/post_migrate/20180125111139_add_unique_pipeline_stage_name_index.rb new file mode 100644 index 00000000000..4fa148b2446 --- /dev/null +++ b/db/post_migrate/20180125111139_add_unique_pipeline_stage_name_index.rb @@ -0,0 +1,17 @@ +class AddUniquePipelineStageNameIndex < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + remove_concurrent_index :ci_stages, [:pipeline_id, :name] + add_concurrent_index :ci_stages, [:pipeline_id, :name], unique: true + end + + def down + remove_concurrent_index :ci_stages, [:pipeline_id, :name], unique: true + add_concurrent_index :ci_stages, [:pipeline_id, :name] + end +end diff --git a/db/schema.rb b/db/schema.rb index 9becd794553..d0802bed8f7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180119121225) do +ActiveRecord::Schema.define(version: 20180125111139) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -450,7 +450,8 @@ ActiveRecord::Schema.define(version: 20180119121225) do t.integer "lock_version" end - add_index "ci_stages", ["pipeline_id", "name"], name: "index_ci_stages_on_pipeline_id_and_name", using: :btree + add_index "ci_stages", ["pipeline_id", "name"], name: "index_ci_stages_on_pipeline_id_and_name", unique: true, using: :btree + add_index "ci_stages", ["pipeline_id", "name"], name: "index_ci_stages_on_pipeline_id_and_name_unique", unique: true, using: :btree add_index "ci_stages", ["pipeline_id"], name: "index_ci_stages_on_pipeline_id", using: :btree add_index "ci_stages", ["project_id"], name: "index_ci_stages_on_project_id", using: :btree |