2016-06-09 12:39:16 +00:00
# rubocop:disable all
2016-03-28 12:27:30 +00:00
# This migration will create one row of NotificationSetting for each Member row
2016-03-30 08:38:03 +00:00
# It can take long time on big instances.
#
# This migration can be done online but with following effects:
# - during migration some users will receive notifications based on their global settings (project/group settings will be ignored)
# - its possible to get duplicate records for notification settings since we don't create uniq index yet
#
2016-03-28 12:27:30 +00:00
class MigrateNewNotificationSetting < ActiveRecord :: Migration
def up
2016-04-14 21:46:18 +00:00
timestamp = Time . now . strftime ( '%F %T' )
2016-03-28 21:39:49 +00:00
execute " INSERT INTO notification_settings ( user_id, source_id, source_type, level, created_at, updated_at ) SELECT user_id, source_id, source_type, notification_level, ' #{ timestamp } ', ' #{ timestamp } ' FROM members WHERE user_id IS NOT NULL "
2016-03-28 12:27:30 +00:00
end
def down
2016-04-08 19:49:01 +00:00
execute " DELETE FROM notification_settings "
2016-03-28 12:27:30 +00:00
end
end