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