Commit 879b416a authored by Mike Kozono's avatar Mike Kozono Committed by Gabriel Mazetto

Add verification indexes to package file registry

parent ce15695c
# frozen_string_literal: true
class AddVerificationIndexesToPackageFileRegistry < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
PENDING_VERIFICATION_INDEX_NAME = "package_file_registry_pending_verification"
FAILED_VERIFICATION_INDEX_NAME = "package_file_registry_failed_verification"
NEEDS_VERIFICATION_INDEX_NAME = "package_file_registry_needs_verification"
disable_ddl_transaction!
def up
add_concurrent_index :package_file_registry, :verified_at, where: "(state = 2 AND verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME
add_concurrent_index :package_file_registry, :verification_retry_at, where: "(state = 2 AND verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME
add_concurrent_index :package_file_registry, :verification_state, where: "(state = 2 AND (verification_state = 0 OR verification_state = 3))", name: NEEDS_VERIFICATION_INDEX_NAME
end
def down
remove_concurrent_index_by_name :package_file_registry, PENDING_VERIFICATION_INDEX_NAME
remove_concurrent_index_by_name :package_file_registry, FAILED_VERIFICATION_INDEX_NAME
remove_concurrent_index_by_name :package_file_registry, NEEDS_VERIFICATION_INDEX_NAME
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_12_08_025254) do ActiveRecord::Schema.define(version: 2020_12_08_031224) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -124,6 +124,9 @@ ActiveRecord::Schema.define(version: 2020_12_08_025254) do ...@@ -124,6 +124,9 @@ ActiveRecord::Schema.define(version: 2020_12_08_025254) do
t.index ["package_file_id"], name: "index_package_file_registry_on_repository_id" t.index ["package_file_id"], name: "index_package_file_registry_on_repository_id"
t.index ["retry_at"], name: "index_package_file_registry_on_retry_at" t.index ["retry_at"], name: "index_package_file_registry_on_retry_at"
t.index ["state"], name: "index_package_file_registry_on_state" t.index ["state"], name: "index_package_file_registry_on_state"
t.index ["verification_retry_at"], name: "package_file_registry_failed_verification", order: "NULLS FIRST", where: "((state = 2) AND (verification_state = 3))"
t.index ["verification_state"], name: "package_file_registry_needs_verification", where: "((state = 2) AND ((verification_state = 0) OR (verification_state = 3)))"
t.index ["verified_at"], name: "package_file_registry_pending_verification", order: "NULLS FIRST", where: "((state = 2) AND (verification_state = 0))"
end end
create_table "project_registry", id: :serial, force: :cascade do |t| create_table "project_registry", id: :serial, force: :cascade do |t|
......
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