From c46a0612706a2570342178fe8f61222034675c38 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 16 Apr 2014 11:02:42 +0300 Subject: [PATCH] Add uniq db index on project_id+iid --- db/migrate/20140416074002_add_index_on_iid.rb | 7 +++++++ db/schema.rb | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 db/migrate/20140416074002_add_index_on_iid.rb diff --git a/db/migrate/20140416074002_add_index_on_iid.rb b/db/migrate/20140416074002_add_index_on_iid.rb new file mode 100644 index 00000000000..cbd09082781 --- /dev/null +++ b/db/migrate/20140416074002_add_index_on_iid.rb @@ -0,0 +1,7 @@ +class AddIndexOnIid < ActiveRecord::Migration + def change + add_index :issues, [:project_id, :iid], unique: true + add_index :merge_requests, [:target_project_id, :iid], unique: true + add_index :milestones, [:project_id, :iid], unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index e53a637af66..17ca752db78 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -93,6 +93,7 @@ ActiveRecord::Schema.define(version: 20140416185734) do add_index "issues", ["author_id"], name: "index_issues_on_author_id", using: :btree add_index "issues", ["created_at"], name: "index_issues_on_created_at", using: :btree add_index "issues", ["milestone_id"], name: "index_issues_on_milestone_id", using: :btree + add_index "issues", ["project_id", "iid"], name: "index_issues_on_project_id_and_iid", unique: true, using: :btree add_index "issues", ["project_id"], name: "index_issues_on_project_id", using: :btree add_index "issues", ["title"], name: "index_issues_on_title", using: :btree @@ -143,6 +144,7 @@ ActiveRecord::Schema.define(version: 20140416185734) do add_index "merge_requests", ["source_branch"], name: "index_merge_requests_on_source_branch", using: :btree add_index "merge_requests", ["source_project_id"], name: "index_merge_requests_on_source_project_id", using: :btree add_index "merge_requests", ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree + add_index "merge_requests", ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid", unique: true, using: :btree add_index "merge_requests", ["title"], name: "index_merge_requests_on_title", using: :btree create_table "milestones", force: true do |t| @@ -157,6 +159,7 @@ ActiveRecord::Schema.define(version: 20140416185734) do end add_index "milestones", ["due_date"], name: "index_milestones_on_due_date", using: :btree + add_index "milestones", ["project_id", "iid"], name: "index_milestones_on_project_id_and_iid", unique: true, using: :btree add_index "milestones", ["project_id"], name: "index_milestones_on_project_id", using: :btree create_table "namespaces", force: true do |t|