Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20230306071456_validate_partitioning_fk_on_p_ci_builds_metadata_partitions.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f07175e82f9a34e6173c5ffee04dd01bf19ec885 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

class ValidatePartitioningFkOnPCiBuildsMetadataPartitions < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!

  SOURCE_TABLE_NAME = :p_ci_builds_metadata
  FK_NAME = :fk_e20479742e_p

  def up
    Gitlab::Database::PostgresPartitionedTable.each_partition(SOURCE_TABLE_NAME) do |partition|
      next unless foreign_key_exists?(partition.identifier, name: FK_NAME)

      validate_foreign_key(partition.identifier, nil, name: FK_NAME)
    end
  end

  def down
    # No-op
  end
end