diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-10 12:07:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-10 12:07:51 +0300 |
commit | 97d4d926630822d0e1a638206909679c962d2f0a (patch) | |
tree | ef885fdbd0f255f901a587fc3d01bdf115fa3a27 /db | |
parent | cfc792b9ca064990e6540cb742e80529ea669a81 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20191206122926_update_index_for_pool_repositories.rb | 24 | ||||
-rw-r--r-- | db/schema.rb | 4 |
2 files changed, 26 insertions, 2 deletions
diff --git a/db/migrate/20191206122926_update_index_for_pool_repositories.rb b/db/migrate/20191206122926_update_index_for_pool_repositories.rb new file mode 100644 index 00000000000..f88e8e94ee1 --- /dev/null +++ b/db/migrate/20191206122926_update_index_for_pool_repositories.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class UpdateIndexForPoolRepositories < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + # This index is less restrictive then the one we already have, no need to + # update data. + add_concurrent_index :pool_repositories, [:source_project_id, :shard_id], unique: true + remove_concurrent_index :pool_repositories, :source_project_id + end + + def down + # Not adding this index as a unique one, since while the new index existed + # we could have created multiple pool repositories for a project. In that + # case this rollback would fail. + add_concurrent_index :pool_repositories, :source_project_id + remove_concurrent_index :pool_repositories, [:source_project_id, :shard_id], unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index b456159291d..da8dba2e83d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_12_04_093410) do +ActiveRecord::Schema.define(version: 2019_12_06_122926) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" @@ -2969,7 +2969,7 @@ ActiveRecord::Schema.define(version: 2019_12_04_093410) do t.integer "source_project_id" t.index ["disk_path"], name: "index_pool_repositories_on_disk_path", unique: true t.index ["shard_id"], name: "index_pool_repositories_on_shard_id" - t.index ["source_project_id"], name: "index_pool_repositories_on_source_project_id", unique: true + t.index ["source_project_id", "shard_id"], name: "index_pool_repositories_on_source_project_id_and_shard_id", unique: true end create_table "programming_languages", id: :serial, force: :cascade do |t| |