diff options
Diffstat (limited to 'db/migrate/20170418103908_delete_orphan_notification_settings.rb')
-rw-r--r-- | db/migrate/20170418103908_delete_orphan_notification_settings.rb | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/db/migrate/20170418103908_delete_orphan_notification_settings.rb b/db/migrate/20170418103908_delete_orphan_notification_settings.rb deleted file mode 100644 index c99729b9127..00000000000 --- a/db/migrate/20170418103908_delete_orphan_notification_settings.rb +++ /dev/null @@ -1,24 +0,0 @@ -class DeleteOrphanNotificationSettings < ActiveRecord::Migration[4.2] - DOWNTIME = false - - def up - execute("DELETE FROM notification_settings WHERE EXISTS (SELECT true FROM (#{orphan_notification_settings}) AS ns WHERE ns.id = notification_settings.id)") - end - - def down - # This is a no-op method to make the migration reversible. - # If someone is trying to rollback for other reasons, we should not throw an Exception. - # raise ActiveRecord::IrreversibleMigration - end - - def orphan_notification_settings - <<-SQL - SELECT notification_settings.id - FROM notification_settings - LEFT OUTER JOIN namespaces - ON namespaces.id = notification_settings.source_id - WHERE notification_settings.source_type = 'Namespace' - AND namespaces.id IS NULL - SQL - end -end |