BigW Consortium Gitlab

20160527020117_remove_notification_settings_for_deleted_projects.rb 399 Bytes
Newer Older
1
# rubocop:disable all
2 3 4 5 6 7 8 9 10 11 12 13 14
class RemoveNotificationSettingsForDeletedProjects < ActiveRecord::Migration
  def up
    execute <<-SQL
      DELETE FROM notification_settings
      WHERE notification_settings.source_type = 'Project'
        AND NOT EXISTS (
              SELECT *
              FROM projects
              WHERE projects.id = notification_settings.source_id
            )
    SQL
  end
end