summaryrefslogtreecommitdiff
path: root/db/migrate/20160527020117_remove_notification_settings_for_deleted_projects.rb
blob: 3e26be7c09c0b6f1db90535e4845caac06286c60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# rubocop:disable all
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