diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-08-25 12:59:21 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-08-25 12:59:21 -0500 |
commit | bbd9a6fe405d0df1c7c9ad09b7c3ff6a0201953f (patch) | |
tree | ebe142b4a13ff41691fdc75b348e718c3989a2df /db | |
parent | 532489dc045d6f0c6a215889be3f1d39097d1c83 (diff) | |
parent | a943ccf10ecf2af3331927cb83268fbc70f43634 (diff) | |
download | gitlab-ce-bbd9a6fe405d0df1c7c9ad09b7c3ff6a0201953f.tar.gz |
Merge branch 'dz-merge-request-version'
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20160725104020_merge_request_diff_remove_uniq.rb | 21 | ||||
-rw-r--r-- | db/migrate/20160725104452_merge_request_diff_add_index.rb | 17 | ||||
-rw-r--r-- | db/schema.rb | 3 |
3 files changed, 39 insertions, 2 deletions
diff --git a/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb b/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb new file mode 100644 index 00000000000..c8cbd2718ff --- /dev/null +++ b/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb @@ -0,0 +1,21 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class MergeRequestDiffRemoveUniq < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + DOWNTIME = false + + def up + if index_exists?(:merge_request_diffs, :merge_request_id) + remove_index :merge_request_diffs, :merge_request_id + end + end + + def down + unless index_exists?(:merge_request_diffs, :merge_request_id) + add_concurrent_index :merge_request_diffs, :merge_request_id, unique: true + end + end +end diff --git a/db/migrate/20160725104452_merge_request_diff_add_index.rb b/db/migrate/20160725104452_merge_request_diff_add_index.rb new file mode 100644 index 00000000000..6d04242dd25 --- /dev/null +++ b/db/migrate/20160725104452_merge_request_diff_add_index.rb @@ -0,0 +1,17 @@ +class MergeRequestDiffAddIndex < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def up + add_concurrent_index :merge_request_diffs, :merge_request_id + end + + def down + if index_exists?(:merge_request_diffs, :merge_request_id) + remove_index :merge_request_diffs, :merge_request_id + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 802c928b2fc..38779065225 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -593,7 +593,7 @@ ActiveRecord::Schema.define(version: 20160823081327) do t.string "start_commit_sha" end - add_index "merge_request_diffs", ["merge_request_id"], name: "index_merge_request_diffs_on_merge_request_id", unique: true, using: :btree + add_index "merge_request_diffs", ["merge_request_id"], name: "index_merge_request_diffs_on_merge_request_id", using: :btree create_table "merge_requests", force: :cascade do |t| t.string "target_branch", null: false @@ -620,7 +620,6 @@ ActiveRecord::Schema.define(version: 20160823081327) do t.string "merge_commit_sha" t.datetime "deleted_at" t.string "in_progress_merge_commit_sha" - t.integer "lock_version" end add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree |