Adds unique constraint to ProjectMirrorData project_id index

This commit is contained in:
Tiago Botelho 2018-05-08 11:57:08 +01:00
parent 4caf58a19b
commit fcb6dd6861
2 changed files with 33 additions and 2 deletions

View file

@ -0,0 +1,31 @@
class AddUniqueConstraintToProjectMirrorDataProjectIdIndex < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index(:project_mirror_data,
:project_id,
unique: true,
name: 'index_project_mirror_data_on_project_id_unique')
remove_concurrent_index_by_name(:project_mirror_data, 'index_project_mirror_data_on_project_id')
rename_index(:project_mirror_data,
'index_project_mirror_data_on_project_id_unique',
'index_project_mirror_data_on_project_id')
end
def down
rename_index(:project_mirror_data,
'index_project_mirror_data_on_project_id',
'index_project_mirror_data_on_project_id_old')
add_concurrent_index(:project_mirror_data, :project_id)
remove_concurrent_index_by_name(:project_mirror_data,
'index_project_mirror_data_on_project_id_old')
end
end

View file

@ -11,7 +11,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: 20180508100222) do ActiveRecord::Schema.define(version: 20180508102840) 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"
@ -1536,7 +1536,7 @@ ActiveRecord::Schema.define(version: 20180508100222) do
end end
add_index "project_mirror_data", ["jid"], name: "index_project_mirror_data_on_jid", using: :btree add_index "project_mirror_data", ["jid"], name: "index_project_mirror_data_on_jid", using: :btree
add_index "project_mirror_data", ["project_id"], name: "index_project_mirror_data_on_project_id", using: :btree add_index "project_mirror_data", ["project_id"], name: "index_project_mirror_data_on_project_id", unique: true, using: :btree
add_index "project_mirror_data", ["status"], name: "index_project_mirror_data_on_status", using: :btree add_index "project_mirror_data", ["status"], name: "index_project_mirror_data_on_status", using: :btree
create_table "project_statistics", force: :cascade do |t| create_table "project_statistics", force: :cascade do |t|