summaryrefslogtreecommitdiff
path: root/db/migrate/20200212014653_rename_security_dashboard_feature_flag_to_instance_security_dashboard.rb
blob: 8d37f6c1dd4a105229518b2a10835d76408a5bc6 (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
# frozen_string_literal: true

class RenameSecurityDashboardFeatureFlagToInstanceSecurityDashboard < ActiveRecord::Migration[6.0]
  DOWNTIME = false

  class FeatureGate < ApplicationRecord
    self.table_name = 'feature_gates'
  end

  def up
    security_dashboard_feature = FeatureGate.find_by(feature_key: :security_dashboard, key: :boolean)

    if security_dashboard_feature.present?
      FeatureGate.safe_find_or_create_by!(
        feature_key: :instance_security_dashboard,
        key: :boolean,
        value: security_dashboard_feature.value
      )
    end
  end

  def down
    FeatureGate.find_by(feature_key: :instance_security_dashboard, key: :boolean)&.delete
  end
end