Add index to notification settings

This commit is contained in:
Felipe Artur 2016-06-03 15:49:34 -03:00
parent ca3c5c295e
commit 8450fe3074
4 changed files with 22 additions and 1 deletions

View file

@ -34,6 +34,7 @@ v 8.9.0 (unreleased)
- Cache project build count in sidebar nav
- Reduce number of queries needed to render issue labels in the sidebar
- Improve error handling importing projects
- Remove duplicated notification settings
- Put project Files and Commits tabs under Code tab
v 8.8.4

View file

@ -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

View file

@ -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

View file

@ -19,8 +19,12 @@ module Gitlab
end
if Database.postgresql?
if args[2].present?
args[2].merge!({ algorithm: :concurrently })
else
args << { algorithm: :concurrently }
end
end
add_index(*args)
end