Commit 9cdf2dc5 authored by Toon Claes's avatar Toon Claes

Add unique constraint design_registry.project_id

The index on design_registry.project_id should be unique. There can
only be one row for each project_id.

Closes https://gitlab.com/gitlab-org/gitlab/issues/33545
parent 7cea781a
# frozen_string_literal: true
class AddUniqueConstraintOnDesignRegistryProjectId < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_design_registry_on_project_id'
def change
# `design_registry` is not in use yet, so no need to create index concurrently
remove_index :design_registry, column: :project_id, name: INDEX_NAME # rubocop: disable Migration/RemoveIndex
add_index :design_registry, :project_id, name: INDEX_NAME, unique: true # rubocop: disable Migration/AddIndex
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_09_23_111102) do ActiveRecord::Schema.define(version: 2019_10_07_122326) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -38,7 +38,7 @@ ActiveRecord::Schema.define(version: 2019_09_23_111102) do ...@@ -38,7 +38,7 @@ ActiveRecord::Schema.define(version: 2019_09_23_111102) do
t.datetime "retry_at" t.datetime "retry_at"
t.datetime "last_synced_at" t.datetime "last_synced_at"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.index ["project_id"], name: "index_design_registry_on_project_id" t.index ["project_id"], name: "index_design_registry_on_project_id", unique: true
t.index ["retry_at"], name: "index_design_registry_on_retry_at" t.index ["retry_at"], name: "index_design_registry_on_retry_at"
t.index ["state"], name: "index_design_registry_on_state" t.index ["state"], name: "index_design_registry_on_state"
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment