summaryrefslogtreecommitdiff
path: root/db/post_migrate/20200117194850_backfill_operations_feature_flags_iid.rb
blob: bc97bd6062d76685210817aae0a1fcdb33d14421 (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
# frozen_string_literal: true

class BackfillOperationsFeatureFlagsIid < ActiveRecord::Migration[5.2]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  ###
  # This should update about 700 rows on gitlab.com
  # Execution time is predicted to take less than a second based on #database-lab results
  # https://gitlab.com/gitlab-org/gitlab/merge_requests/22175#migration-performance
  ###
  def up
    execute('LOCK operations_feature_flags IN ACCESS EXCLUSIVE MODE')

    backfill_iids('operations_feature_flags')

    change_column_null :operations_feature_flags, :iid, false
  end

  def down
    change_column_null :operations_feature_flags, :iid, true
  end
end