summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-05-08 11:57:08 +0100
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-05-08 11:57:08 +0100
commitfcb6dd6861adf45637009d2772df2db9683746e8 (patch)
treecd7defee9f521e535f89a12e5877cb2b75527dc1 /db
parent4caf58a19b0e738889b512598c790582c24ee5c8 (diff)
downloadgitlab-ce-fcb6dd6861adf45637009d2772df2db9683746e8.tar.gz
Adds unique constraint to ProjectMirrorData project_id index
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb31
-rw-r--r--db/schema.rb4
2 files changed, 33 insertions, 2 deletions
diff --git a/db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb b/db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb
new file mode 100644
index 00000000000..acb976b52fa
--- /dev/null
+++ b/db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb
@@ -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
diff --git a/db/schema.rb b/db/schema.rb
index 6f40f70d350..ec0aa5f6603 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# 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
enable_extension "plpgsql"
@@ -1536,7 +1536,7 @@ ActiveRecord::Schema.define(version: 20180508100222) do
end
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
create_table "project_statistics", force: :cascade do |t|