diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-06 19:14:01 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-06 19:14:01 +0000 |
commit | 0ba21860c5ca3df1a1aca916cb0094802e76fd75 (patch) | |
tree | f12ead214d1b8003a9acabadf6f1d079042d150a /db/migrate | |
parent | f73292e471232683f314f58e9c58bacac5beb519 (diff) | |
parent | 9264203103bbd2b4f46ce777304f210b07765c43 (diff) | |
download | gitlab-ce-0ba21860c5ca3df1a1aca916cb0094802e76fd75.tar.gz |
Merge branch 'issue_3359' into 'master'
Remove duplicated notification settings and add unique index
See merge request !4472
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20160603180330_remove_duplicated_notification_settings.rb | 7 | ||||
-rw-r--r-- | db/migrate/20160603182247_add_index_to_notification_settings.rb | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/db/migrate/20160603180330_remove_duplicated_notification_settings.rb b/db/migrate/20160603180330_remove_duplicated_notification_settings.rb new file mode 100644 index 00000000000..c2fcac4c53d --- /dev/null +++ b/db/migrate/20160603180330_remove_duplicated_notification_settings.rb @@ -0,0 +1,7 @@ +class RemoveDuplicatedNotificationSettings < ActiveRecord::Migration + def up + execute <<-SQL + DELETE FROM notification_settings WHERE id NOT IN ( SELECT min_id from (SELECT MIN(id) as min_id FROM notification_settings GROUP BY user_id, source_type, source_id) as dups ) + SQL + end +end diff --git a/db/migrate/20160603182247_add_index_to_notification_settings.rb b/db/migrate/20160603182247_add_index_to_notification_settings.rb new file mode 100644 index 00000000000..06462042b09 --- /dev/null +++ b/db/migrate/20160603182247_add_index_to_notification_settings.rb @@ -0,0 +1,9 @@ +class AddIndexToNotificationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + def change + add_concurrent_index :notification_settings, [:user_id, :source_id, :source_type], { unique: true, name: "index_notifications_on_user_id_and_source_id_and_source_type" } + end +end |