diff options
Diffstat (limited to 'db/migrate/20210721174453_remove_schedule_and_status_null_constraints_from_pending_escalations_alert.rb')
-rw-r--r-- | db/migrate/20210721174453_remove_schedule_and_status_null_constraints_from_pending_escalations_alert.rb | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/db/migrate/20210721174453_remove_schedule_and_status_null_constraints_from_pending_escalations_alert.rb b/db/migrate/20210721174453_remove_schedule_and_status_null_constraints_from_pending_escalations_alert.rb deleted file mode 100644 index 89adaf89693..00000000000 --- a/db/migrate/20210721174453_remove_schedule_and_status_null_constraints_from_pending_escalations_alert.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -class RemoveScheduleAndStatusNullConstraintsFromPendingEscalationsAlert < ActiveRecord::Migration[6.1] - include Gitlab::Database::MigrationHelpers - - # In preparation of removal of these columns in 14.3. - def up - with_lock_retries do - change_column_null :incident_management_pending_alert_escalations, :status, true - change_column_null :incident_management_pending_alert_escalations, :schedule_id, true - end - end - - def down - backfill_from_rules_and_disallow_column_null :status, value: :status - backfill_from_rules_and_disallow_column_null :schedule_id, value: :oncall_schedule_id - end - - private - - def backfill_from_rules_and_disallow_column_null(column, value:) - with_lock_retries do - execute <<~SQL - UPDATE incident_management_pending_alert_escalations AS escalations - SET #{column} = rules.#{value} - FROM incident_management_escalation_rules AS rules - WHERE rule_id = rules.id - AND escalations.#{column} IS NULL - SQL - - change_column_null :incident_management_pending_alert_escalations, column, false - end - end -end |