Add unique constraint to trending_projects#project_id.
This commit is contained in:
parent
54a575f1bb
commit
313f4d49d7
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Add unique constraint to trending_projects#project_id.
|
||||||
|
merge_request: 16846
|
||||||
|
author:
|
||||||
|
type: other
|
|
@ -0,0 +1,19 @@
|
||||||
|
class AddUniqueConstraintToTrendingProjectsProjectId < ActiveRecord::Migration
|
||||||
|
include Gitlab::Database::MigrationHelpers
|
||||||
|
|
||||||
|
DOWNTIME = false
|
||||||
|
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def up
|
||||||
|
add_concurrent_index :trending_projects, :project_id, unique: true, name: 'index_trending_projects_on_project_id_unique'
|
||||||
|
remove_concurrent_index_by_name :trending_projects, 'index_trending_projects_on_project_id'
|
||||||
|
rename_index :trending_projects, 'index_trending_projects_on_project_id_unique', 'index_trending_projects_on_project_id'
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
rename_index :trending_projects, 'index_trending_projects_on_project_id', 'index_trending_projects_on_project_id_old'
|
||||||
|
add_concurrent_index :trending_projects, :project_id
|
||||||
|
remove_concurrent_index_by_name :trending_projects, 'index_trending_projects_on_project_id_old'
|
||||||
|
end
|
||||||
|
end
|
|
@ -1727,7 +1727,7 @@ ActiveRecord::Schema.define(version: 20180201145907) do
|
||||||
t.integer "project_id", null: false
|
t.integer "project_id", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "trending_projects", ["project_id"], name: "index_trending_projects_on_project_id", using: :btree
|
add_index "trending_projects", ["project_id"], name: "index_trending_projects_on_project_id", unique: true, using: :btree
|
||||||
|
|
||||||
create_table "u2f_registrations", force: :cascade do |t|
|
create_table "u2f_registrations", force: :cascade do |t|
|
||||||
t.text "certificate"
|
t.text "certificate"
|
||||||
|
|
Loading…
Reference in New Issue