2017-08-09 13:49:30 +00:00
|
|
|
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
|
|
|
|
# for more information on how to write migrations for GitLab.
|
|
|
|
|
2018-11-13 07:27:31 +00:00
|
|
|
class AddBroadcastMessageNotNullConstraints < ActiveRecord::Migration[4.2]
|
2017-08-09 13:49:30 +00:00
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
# Set this constant to true if this migration requires downtime.
|
|
|
|
DOWNTIME = false
|
|
|
|
|
|
|
|
COLUMNS = %i[starts_at ends_at created_at updated_at message_html]
|
|
|
|
|
2017-08-14 15:05:32 +00:00
|
|
|
class BroadcastMessage < ActiveRecord::Base
|
|
|
|
self.table_name = 'broadcast_messages'
|
|
|
|
end
|
|
|
|
|
|
|
|
def up
|
2017-08-09 13:49:30 +00:00
|
|
|
COLUMNS.each do |column|
|
2017-08-14 15:05:32 +00:00
|
|
|
BroadcastMessage.where(column => nil).delete_all
|
|
|
|
|
2017-08-09 13:49:30 +00:00
|
|
|
change_column_null :broadcast_messages, column, false
|
|
|
|
end
|
|
|
|
end
|
2017-08-14 15:05:32 +00:00
|
|
|
|
|
|
|
def down
|
|
|
|
COLUMNS.each do |column|
|
|
|
|
change_column_null :broadcast_messages, column, true
|
|
|
|
end
|
|
|
|
end
|
2017-08-09 13:49:30 +00:00
|
|
|
end
|