Add index to last verification columns on repository states

parent eb8a9058
......@@ -2179,6 +2179,8 @@ ActiveRecord::Schema.define(version: 20181204135932) do
t.datetime_with_timezone "last_wiki_verification_ran_at"
t.index ["last_repository_verification_failure"], name: "idx_repository_states_on_repository_failure_partial", where: "(last_repository_verification_failure IS NOT NULL)", using: :btree
t.index ["last_wiki_verification_failure"], name: "idx_repository_states_on_wiki_failure_partial", where: "(last_wiki_verification_failure IS NOT NULL)", using: :btree
t.index ["project_id", "last_repository_verification_ran_at"], name: "idx_repository_states_on_last_repository_verification_ran_at", where: "((repository_verification_checksum IS NOT NULL) AND (last_repository_verification_failure IS NULL))", using: :btree
t.index ["project_id", "last_wiki_verification_ran_at"], name: "idx_repository_states_on_last_wiki_verification_ran_at", where: "((wiki_verification_checksum IS NOT NULL) AND (last_wiki_verification_failure IS NULL))", using: :btree
t.index ["project_id"], name: "idx_repository_states_outdated_checksums", where: "(((repository_verification_checksum IS NULL) AND (last_repository_verification_failure IS NULL)) OR ((wiki_verification_checksum IS NULL) AND (last_wiki_verification_failure IS NULL)))", using: :btree
t.index ["project_id"], name: "index_project_repository_states_on_project_id", unique: true, using: :btree
end
......
# frozen_string_literal: true
class AddIndexToLastVerificationColumnsOnProjectRepositoryStates < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
REPOSITORY_INDEX_NAME = 'idx_repository_states_on_last_repository_verification_ran_at'
WIKI_INDEX_NAME = 'idx_repository_states_on_last_wiki_verification_ran_at'
disable_ddl_transaction!
def up
add_concurrent_index(:project_repository_states,
[:project_id, :last_repository_verification_ran_at],
name: REPOSITORY_INDEX_NAME,
where: 'repository_verification_checksum IS NOT NULL AND last_repository_verification_failure IS NULL')
add_concurrent_index(:project_repository_states,
[:project_id, :last_wiki_verification_ran_at],
name: WIKI_INDEX_NAME,
where: 'wiki_verification_checksum IS NOT NULL AND last_wiki_verification_failure IS NULL')
end
def down
remove_concurrent_index_by_name(:project_repository_states, REPOSITORY_INDEX_NAME)
remove_concurrent_index_by_name(:project_repository_states, WIKI_INDEX_NAME)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment