FIX: Set null high_priority columns to false in high priority notification migration (#9335)

Some DBs failed on this migration, possibly due to new records being added, with the error

ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR:  column "high_priority" contains null values

Luckily, the migration is retryable as is.
This commit is contained in:
Martin Brennan 2020-04-02 09:32:39 +10:00 committed by GitHub
parent cade4957ae
commit 393215266f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,10 @@ class AddHighPriorityColumnToNotifications < ActiveRecord::Migration[6.0]
ALTER TABLE notifications ALTER COLUMN high_priority SET DEFAULT FALSE;
SQL
execute <<~SQL
UPDATE notifications SET high_priority = FALSE WHERE high_priority IS NULL;
SQL
execute <<~SQL
ALTER TABLE notifications ALTER COLUMN high_priority SET NOT NULL;
SQL