summaryrefslogtreecommitdiff
path: root/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb')
-rw-r--r--db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb55
1 files changed, 0 insertions, 55 deletions
diff --git a/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb b/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb
deleted file mode 100644
index 8ff26130cba..00000000000
--- a/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-class ConvertCustomNotificationSettingsToColumns < ActiveRecord::Migration[4.2]
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
-
- disable_ddl_transaction!
-
- class NotificationSetting < ActiveRecord::Base
- self.table_name = 'notification_settings'
-
- store :events, coder: JSON
- end
-
- EMAIL_EVENTS = [
- :new_note,
- :new_issue,
- :reopen_issue,
- :close_issue,
- :reassign_issue,
- :new_merge_request,
- :reopen_merge_request,
- :close_merge_request,
- :reassign_merge_request,
- :merge_merge_request,
- :failed_pipeline,
- :success_pipeline
- ]
-
- # We only need to migrate (up or down) rows where at least one of these
- # settings is set.
- def up
- NotificationSetting.where("events LIKE '%true%'").find_each do |notification_setting|
- EMAIL_EVENTS.each do |event|
- notification_setting[event] = notification_setting.events[event]
- end
-
- notification_setting[:events] = nil
- notification_setting.save!
- end
- end
-
- def down
- NotificationSetting.where(EMAIL_EVENTS.join(' OR ')).find_each do |notification_setting|
- events = {}
-
- EMAIL_EVENTS.each do |event|
- events[event] = !!notification_setting.public_send(event)
- notification_setting[event] = nil
- end
-
- notification_setting[:events] = events
- notification_setting.save!
- end
- end
-end