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

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

class DeleteProjectCalloutThree < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!
  restrict_gitlab_migration gitlab_schema: :gitlab_main

  BATCH_SIZE = 1000
  ULTIMATE_FEATURE_REMOVAL_BANNER_FEATURE_NAME = 3

  def up
    each_batch_range('user_project_callouts', scope: ->(table) { table.all }, of: BATCH_SIZE) do |min, max|
      execute <<~SQL
        DELETE FROM user_project_callouts
        WHERE feature_name = #{ULTIMATE_FEATURE_REMOVAL_BANNER_FEATURE_NAME}
        AND id BETWEEN #{min} AND #{max}
      SQL
    end
  end

  def down
    # NO-OP
  end
end