2016-06-09 08:39:16 -04:00
# rubocop:disable all
2016-03-28 08:27:30 -04:00
# This migration will create one row of NotificationSetting for each Member row
2016-03-30 04:38:03 -04: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 08:27:30 -04:00
class MigrateNewNotificationSetting < ActiveRecord :: Migration
def up
2016-04-14 17:46:18 -04:00
timestamp = Time . now . strftime ( '%F %T' )
2016-03-28 17:39:49 -04: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 08:27:30 -04:00
end
def down
2016-04-08 15:49:01 -04:00
execute " DELETE FROM notification_settings "
2016-03-28 08:27:30 -04:00
end
end