Remove more notification migrations

pull/9800/head
Oliver Günther 3 years ago
parent 89a4ef53a6
commit 1e736cbdf0
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 24
      db/migrate/20210701073944_add_digest_setting.rb
  2. 19
      db/migrate/20210914065555_cleanup_notifications.rb

@ -1,34 +1,12 @@
class AddDigestSetting < ActiveRecord::Migration[6.1]
def up
insert_default_digest_channel
# No-op
end
def down
remove_digest_channels
end
def insert_default_digest_channel
execute <<~SQL
INSERT INTO
notification_settings
(user_id,
channel,
involved,
mentioned,
watched)
SELECT
id,
2,
true,
true,
true
FROM
users
WHERE
type = 'User'
SQL
end
# Removes all digest channels. Includes non default channels as those might
# also have been added not by the migration but in the cause of the functionality
# the migration was added for.

@ -55,25 +55,6 @@ class CleanupNotifications < ActiveRecord::Migration[6.1]
where: "project_id IS NOT NULL",
name: 'index_notification_settings_unique_project'
end
# Set all channels to ian
execute <<~SQL.squish
UPDATE notification_settings SET channel = 0;
SQL
# Restore notification settings
execute <<~SQL.squish
INSERT INTO notification_settings
(project_id, user_id, channel, watched, involved, mentioned,
work_package_commented, work_package_created, work_package_processed, work_package_prioritized, work_package_scheduled)
SELECT project_id, user_id, channel + 1, watched, involved, mentioned,
work_package_commented, work_package_created, work_package_processed, work_package_prioritized, work_package_scheduled
FROM notification_settings
UNION
SELECT project_id, user_id, channel + 2, watched, involved, mentioned,
work_package_commented, work_package_created, work_package_processed, work_package_prioritized, work_package_scheduled
FROM notification_settings;
SQL
end
# rubocop:enable Metrics/AbcSize
end

Loading…
Cancel
Save