Commit c46a0612706a2570342178fe8f61222034675c38
1 parent
2a99f184
Exists in
spb-stable
and in
2 other branches
Add uniq db index on project_id+iid
Showing
2 changed files
with
10 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | +class AddIndexOnIid < ActiveRecord::Migration | |
| 2 | + def change | |
| 3 | + add_index :issues, [:project_id, :iid], unique: true | |
| 4 | + add_index :merge_requests, [:target_project_id, :iid], unique: true | |
| 5 | + add_index :milestones, [:project_id, :iid], unique: true | |
| 6 | + end | |
| 7 | +end | ... | ... |
db/schema.rb
| ... | ... | @@ -93,6 +93,7 @@ ActiveRecord::Schema.define(version: 20140416185734) do |
| 93 | 93 | add_index "issues", ["author_id"], name: "index_issues_on_author_id", using: :btree |
| 94 | 94 | add_index "issues", ["created_at"], name: "index_issues_on_created_at", using: :btree |
| 95 | 95 | add_index "issues", ["milestone_id"], name: "index_issues_on_milestone_id", using: :btree |
| 96 | + add_index "issues", ["project_id", "iid"], name: "index_issues_on_project_id_and_iid", unique: true, using: :btree | |
| 96 | 97 | add_index "issues", ["project_id"], name: "index_issues_on_project_id", using: :btree |
| 97 | 98 | add_index "issues", ["title"], name: "index_issues_on_title", using: :btree |
| 98 | 99 | |
| ... | ... | @@ -143,6 +144,7 @@ ActiveRecord::Schema.define(version: 20140416185734) do |
| 143 | 144 | add_index "merge_requests", ["source_branch"], name: "index_merge_requests_on_source_branch", using: :btree |
| 144 | 145 | add_index "merge_requests", ["source_project_id"], name: "index_merge_requests_on_source_project_id", using: :btree |
| 145 | 146 | add_index "merge_requests", ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree |
| 147 | + add_index "merge_requests", ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid", unique: true, using: :btree | |
| 146 | 148 | add_index "merge_requests", ["title"], name: "index_merge_requests_on_title", using: :btree |
| 147 | 149 | |
| 148 | 150 | create_table "milestones", force: true do |t| |
| ... | ... | @@ -157,6 +159,7 @@ ActiveRecord::Schema.define(version: 20140416185734) do |
| 157 | 159 | end |
| 158 | 160 | |
| 159 | 161 | add_index "milestones", ["due_date"], name: "index_milestones_on_due_date", using: :btree |
| 162 | + add_index "milestones", ["project_id", "iid"], name: "index_milestones_on_project_id_and_iid", unique: true, using: :btree | |
| 160 | 163 | add_index "milestones", ["project_id"], name: "index_milestones_on_project_id", using: :btree |
| 161 | 164 | |
| 162 | 165 | create_table "namespaces", force: true do |t| | ... | ... |