summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-05-31 16:51:04 +0000
committerStan Hu <stanhu@gmail.com>2016-05-31 16:51:04 +0000
commite87149a12bef96b1870777d705a6eb4bc48708af (patch)
treefa59399110016e14aaa6b40fa93ebfd52f69b97b /db
parent5011eeb16eaf8f2ae021b4caa6a59cfe77ae2713 (diff)
parent4da07781573d830244c001f606fa30260e38c472 (diff)
downloadgitlab-ce-e87149a12bef96b1870777d705a6eb4bc48708af.tar.gz
Merge branch 'remove-dangling-notification-settings' into 'master'
Remove project notification settings associated with deleted projects On GitLab.com, there are 1560 project notification settings with no valid project all created on 2016-04-15 10:38:53 for some reason. This migration should purge those entries. b8f38437 should prevent this issue from occurring in the first place. Closes gitlab-com/support-forum#678 See merge request !4311
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20160527020117_remove_notification_settings_for_deleted_projects.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/db/migrate/20160527020117_remove_notification_settings_for_deleted_projects.rb b/db/migrate/20160527020117_remove_notification_settings_for_deleted_projects.rb
new file mode 100644
index 00000000000..7910120b4e0
--- /dev/null
+++ b/db/migrate/20160527020117_remove_notification_settings_for_deleted_projects.rb
@@ -0,0 +1,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