diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-08-15 11:13:37 +0300 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-08-15 18:35:38 +0300 |
commit | 7c135bb4a0fc1701a676f1f1c5d6d94dfe1dc91f (patch) | |
tree | 9a1987e1682508669061d685bed86363d2acc244 | |
parent | 3ef2fb2b1b43b747b1ccf9ddd394171385774a50 (diff) |
Merge branch 'fix-broadcast-messages-migration' into 'master'
Remove invalid broadcast messages before migrating
See merge request !13538
-rw-r--r-- | db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb b/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb index 13e8ef52f22..5551fb51a6e 100644 --- a/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb +++ b/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb @@ -9,9 +9,21 @@ class AddBroadcastMessageNotNullConstraints < ActiveRecord::Migration 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| + BroadcastMessage.where(column => nil).delete_all + change_column_null :broadcast_messages, column, false end end + + def down + COLUMNS.each do |column| + change_column_null :broadcast_messages, column, true + end + end end |