summaryrefslogtreecommitdiff
path: root/db/migrate/20211202094944_move_loose_fk_deleted_records_to_dynamic_schema.rb
blob: 84bc551d2b530e4a49891e75617a9eab1c85eaa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

class MoveLooseFkDeletedRecordsToDynamicSchema < Gitlab::Database::Migration[1.0]
  enable_lock_retries!

  def up
    if table_exists?('gitlab_partitions_static.loose_foreign_keys_deleted_records_1')
      execute 'ALTER TABLE gitlab_partitions_static.loose_foreign_keys_deleted_records_1 SET SCHEMA gitlab_partitions_dynamic'
    end
  end

  def down
    if table_exists?('gitlab_partitions_dynamic.loose_foreign_keys_deleted_records_1')
      execute 'ALTER TABLE gitlab_partitions_dynamic.loose_foreign_keys_deleted_records_1 SET SCHEMA gitlab_partitions_static'
    end
  end
end