Commit c8997ae5 authored by Yorick Peterse's avatar Yorick Peterse

Remove invalid broadcast messages before migrating

This prevents the migration from failing to set "NOT NULL" constraints
when some rows contain NULL values that are no longer allowed.
parent 12cdc461
...@@ -9,9 +9,21 @@ class AddBroadcastMessageNotNullConstraints < ActiveRecord::Migration ...@@ -9,9 +9,21 @@ class AddBroadcastMessageNotNullConstraints < ActiveRecord::Migration
COLUMNS = %i[starts_at ends_at created_at updated_at message_html] COLUMNS = %i[starts_at ends_at created_at updated_at message_html]
def change class BroadcastMessage < ActiveRecord::Base
self.table_name = 'broadcast_messages'
end
def up
COLUMNS.each do |column| COLUMNS.each do |column|
BroadcastMessage.where(column => nil).delete_all
change_column_null :broadcast_messages, column, false change_column_null :broadcast_messages, column, false
end end
end end
def down
COLUMNS.each do |column|
change_column_null :broadcast_messages, column, true
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment