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

20221102090940_create_next_ci_partitions_record.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4bd89a70daa754cb07e57f7113aec5da2c85d391 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

class CreateNextCiPartitionsRecord < Gitlab::Database::Migration[2.0]
  NEXT_PARTITION_ID = 101

  disable_ddl_transaction!
  restrict_gitlab_migration gitlab_schema: :gitlab_ci

  def up
    return unless Gitlab.com?

    execute(<<~SQL)
      INSERT INTO "ci_partitions" ("id", "created_at", "updated_at")
        VALUES (#{NEXT_PARTITION_ID}, now(), now())
        ON CONFLICT DO NOTHING;
    SQL

    reset_pk_sequence!('ci_partitions')
  end

  def down
    return unless Gitlab.com?

    execute(<<~SQL)
      DELETE FROM "ci_partitions"
        WHERE "ci_partitions"."id" = #{NEXT_PARTITION_ID};
    SQL
  end
end