diff options
Diffstat (limited to 'db/migrate/20210313045845_add_verification_indexes_to_snippet_repositories.rb')
-rw-r--r-- | db/migrate/20210313045845_add_verification_indexes_to_snippet_repositories.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/db/migrate/20210313045845_add_verification_indexes_to_snippet_repositories.rb b/db/migrate/20210313045845_add_verification_indexes_to_snippet_repositories.rb new file mode 100644 index 00000000000..ebbc1126aa2 --- /dev/null +++ b/db/migrate/20210313045845_add_verification_indexes_to_snippet_repositories.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class AddVerificationIndexesToSnippetRepositories < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + VERIFICATION_STATE_INDEX_NAME = "index_snippet_repositories_verification_state" + PENDING_VERIFICATION_INDEX_NAME = "index_snippet_repositories_pending_verification" + FAILED_VERIFICATION_INDEX_NAME = "index_snippet_repositories_failed_verification" + NEEDS_VERIFICATION_INDEX_NAME = "index_snippet_repositories_needs_verification" + + disable_ddl_transaction! + + def up + add_concurrent_index :snippet_repositories, :verification_state, name: VERIFICATION_STATE_INDEX_NAME + add_concurrent_index :snippet_repositories, :verified_at, where: "(verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME + add_concurrent_index :snippet_repositories, :verification_retry_at, where: "(verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME + add_concurrent_index :snippet_repositories, :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME + end + + def down + remove_concurrent_index_by_name :snippet_repositories, VERIFICATION_STATE_INDEX_NAME + remove_concurrent_index_by_name :snippet_repositories, PENDING_VERIFICATION_INDEX_NAME + remove_concurrent_index_by_name :snippet_repositories, FAILED_VERIFICATION_INDEX_NAME + remove_concurrent_index_by_name :snippet_repositories, NEEDS_VERIFICATION_INDEX_NAME + end +end |