summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-05-26 19:19:11 -0700
committerStan Hu <stanhu@gmail.com>2016-05-31 08:50:18 -0700
commit4da07781573d830244c001f606fa30260e38c472 (patch)
tree9c4a9c95b55a8c8285ee455877716f6ea5c84082
parentef4fedc18f5e2475aa36cc4327a76a496567c6fc (diff)
downloadgitlab-ce-4da07781573d830244c001f606fa30260e38c472.tar.gz
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
-rw-r--r--CHANGELOG1
-rw-r--r--db/migrate/20160527020117_remove_notification_settings_for_deleted_projects.rb13
2 files changed, 14 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 98e24dc63b1..8b3b60b5f59 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ v 8.9.0 (unreleased)
- Allow enabling wiki page events from Webhook management UI
- Allow forking projects with restricted visibility level
- Improve note validation to prevent errors when creating invalid note via API
+ - Remove project notification settings associated with deleted projects
- Redesign navigation for project pages
- Fix groups API to list only user's accessible projects
- Redesign account and email confirmation emails
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