0
0
Fork 0

Add NOT NULL requirement to account columns on AccountPin (#33244)

This commit is contained in:
Matt Jankowski 2024-12-10 10:50:49 -05:00 committed by GitHub
parent e76aff7de5
commit e4e35ab134
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 5 deletions

View file

@ -0,0 +1,23 @@
# frozen_string_literal: true
class AddNotNullToAccountPinAccountColumns < ActiveRecord::Migration[7.2]
def up
connection.execute(<<~SQL.squish)
DELETE FROM account_pins
WHERE account_id IS NULL
OR target_account_id IS NULL
SQL
safety_assured do
change_column_null :account_pins, :account_id, false
change_column_null :account_pins, :target_account_id, false
end
end
def down
safety_assured do
change_column_null :account_pins, :account_id, true
change_column_null :account_pins, :target_account_id, true
end
end
end