summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220322132242_update_pages_onboarding_state.rb
blob: 896ab78a26679345e0697ef1e43a5a01ce162ba1 (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
30
31
32
# frozen_string_literal: true

class UpdatePagesOnboardingState < Gitlab::Database::Migration[1.0]
  disable_ddl_transaction!
  BATCH_SIZE = 75

  def up
    define_batchable_model(
      :project_pages_metadata
    ).where(
      deployed: true
    ).each_batch(
      of: BATCH_SIZE,
      column: :project_id
    ) do |batch|
      batch.update_all(onboarding_complete: true)
    end
  end

  def down
    define_batchable_model(
      :project_pages_metadata
    ).where(
      onboarding_complete: true
    ).each_batch(
      of: BATCH_SIZE,
      column: :project_id
    ) do |batch|
      batch.update_all(onboarding_complete: false)
    end
  end
end