diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20210331125111_add_default_target_project.rb | 17 | ||||
-rw-r--r-- | db/post_migrate/20210402005225_add_source_and_level_index_on_notification_settings.rb | 24 | ||||
-rw-r--r-- | db/schema_migrations/20210331125111 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20210402005225 | 1 | ||||
-rw-r--r-- | db/structure.sql | 5 |
5 files changed, 45 insertions, 3 deletions
diff --git a/db/migrate/20210331125111_add_default_target_project.rb b/db/migrate/20210331125111_add_default_target_project.rb new file mode 100644 index 00000000000..1a2c5ccca7d --- /dev/null +++ b/db/migrate/20210331125111_add_default_target_project.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddDefaultTargetProject < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + def up + with_lock_retries do + add_column :project_settings, :mr_default_target_self, :boolean, default: false, null: false + end + end + + def down + with_lock_retries do + remove_column :project_settings, :mr_default_target_self + end + end +end diff --git a/db/post_migrate/20210402005225_add_source_and_level_index_on_notification_settings.rb b/db/post_migrate/20210402005225_add_source_and_level_index_on_notification_settings.rb new file mode 100644 index 00000000000..a29babca93e --- /dev/null +++ b/db/post_migrate/20210402005225_add_source_and_level_index_on_notification_settings.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class AddSourceAndLevelIndexOnNotificationSettings < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_WITH_SOURCE_LEVEL_USER_NAME = 'index_notification_settings_on_source_and_level_and_user' + INDEX_WITH_SOURCE_NAME = 'index_notification_settings_on_source_id_and_source_type' + INDEX_WITH_USER_NAME = 'index_notification_settings_on_user_id' + + disable_ddl_transaction! + + def up + add_concurrent_index :notification_settings, [:source_id, :source_type, :level, :user_id], name: INDEX_WITH_SOURCE_LEVEL_USER_NAME + remove_concurrent_index_by_name :notification_settings, INDEX_WITH_SOURCE_NAME # Above index expands this index + remove_concurrent_index_by_name :notification_settings, INDEX_WITH_USER_NAME # It is redundant as we already have unique index on (user_id, source_id, source_type) + end + + def down + add_concurrent_index :notification_settings, [:source_id, :source_type], name: INDEX_WITH_SOURCE_NAME + add_concurrent_index :notification_settings, [:user_id], name: INDEX_WITH_USER_NAME + remove_concurrent_index_by_name :notification_settings, INDEX_WITH_SOURCE_LEVEL_USER_NAME + end +end diff --git a/db/schema_migrations/20210331125111 b/db/schema_migrations/20210331125111 new file mode 100644 index 00000000000..7e6429b4289 --- /dev/null +++ b/db/schema_migrations/20210331125111 @@ -0,0 +1 @@ +8c7343dafaa036115e85f30d2d096d14279c80de99f49b969039ed3afa5acdf6
\ No newline at end of file diff --git a/db/schema_migrations/20210402005225 b/db/schema_migrations/20210402005225 new file mode 100644 index 00000000000..767b1307ca7 --- /dev/null +++ b/db/schema_migrations/20210402005225 @@ -0,0 +1 @@ +6c44623655732e9c2916f7a71d51f53e819a216b8936d20d28d6acf37cc94fdf
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 94779cafdc3..ccb496261d1 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -16520,6 +16520,7 @@ CREATE TABLE project_settings ( allow_editing_commit_messages boolean DEFAULT false NOT NULL, prevent_merge_without_jira_issue boolean DEFAULT false NOT NULL, cve_id_request_enabled boolean DEFAULT true NOT NULL, + mr_default_target_self boolean DEFAULT false NOT NULL, CONSTRAINT check_bde223416c CHECK ((show_default_award_emojis IS NOT NULL)) ); @@ -23229,9 +23230,7 @@ CREATE INDEX index_notes_on_project_id_and_noteable_type ON notes USING btree (p CREATE INDEX index_notes_on_review_id ON notes USING btree (review_id); -CREATE INDEX index_notification_settings_on_source_id_and_source_type ON notification_settings USING btree (source_id, source_type); - -CREATE INDEX index_notification_settings_on_user_id ON notification_settings USING btree (user_id); +CREATE INDEX index_notification_settings_on_source_and_level_and_user ON notification_settings USING btree (source_id, source_type, level, user_id); CREATE UNIQUE INDEX index_notifications_on_user_id_and_source_id_and_source_type ON notification_settings USING btree (user_id, source_id, source_type); |