summaryrefslogtreecommitdiff
path: root/db/migrate/20211217050753_remove_artifacts_archive_id_foreign_key_from_project_pages_metadata.rb
blob: fa81fa512aea75a065f1a0f7db0135081afc8ba5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class RemoveArtifactsArchiveIdForeignKeyFromProjectPagesMetadata < Gitlab::Database::Migration[1.0]
  CONSTRAINT_NAME = 'fk_69366a119e'

  disable_ddl_transaction!

  def up
    with_lock_retries do
      execute('lock table ci_job_artifacts, project_pages_metadata in access exclusive mode')

      remove_foreign_key :project_pages_metadata, to_table: :ci_job_artifacts, column: :artifacts_archive_id, on_delete: :nullify, name: CONSTRAINT_NAME
    end
  end

  def down
    add_concurrent_foreign_key :project_pages_metadata, :ci_job_artifacts, column: :artifacts_archive_id, on_delete: :nullify, name: CONSTRAINT_NAME
  end
end