diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-17 12:08:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-17 12:08:20 +0300 |
commit | 91c2554bcf93c3c41aa830da4dd7a2d4b7483e2d (patch) | |
tree | db4ba29b7ad5398b3eebd845c442d4c26558817c /db | |
parent | 3974bc83f3bfc8a7757dcac0319e966042dc4356 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20220420061439_add_notes_null_discussion_id_temp_index.rb | 16 | ||||
-rw-r--r-- | db/post_migrate/20220420061450_backfill_null_note_discussion_ids.rb | 31 | ||||
-rw-r--r-- | db/schema_migrations/20220420061439 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20220420061450 | 1 | ||||
-rw-r--r-- | db/structure.sql | 2 |
5 files changed, 51 insertions, 0 deletions
diff --git a/db/post_migrate/20220420061439_add_notes_null_discussion_id_temp_index.rb b/db/post_migrate/20220420061439_add_notes_null_discussion_id_temp_index.rb new file mode 100644 index 00000000000..35a6d5f5b10 --- /dev/null +++ b/db/post_migrate/20220420061439_add_notes_null_discussion_id_temp_index.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddNotesNullDiscussionIdTempIndex < Gitlab::Database::Migration[2.0] + # Temporary index to be removed in 15.0 https://gitlab.com/gitlab-org/gitlab/-/issues/357581 + INDEX_NAME = 'tmp_index_notes_on_id_where_discussion_id_is_null' + + disable_ddl_transaction! + + def up + add_concurrent_index :notes, :id, where: 'discussion_id IS NULL', name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :notes, INDEX_NAME + end +end diff --git a/db/post_migrate/20220420061450_backfill_null_note_discussion_ids.rb b/db/post_migrate/20220420061450_backfill_null_note_discussion_ids.rb new file mode 100644 index 00000000000..8880bc2f748 --- /dev/null +++ b/db/post_migrate/20220420061450_backfill_null_note_discussion_ids.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class BackfillNullNoteDiscussionIds < Gitlab::Database::Migration[2.0] + MIGRATION = 'BackfillNoteDiscussionId' + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 10_000 + + restrict_gitlab_migration gitlab_schema: :gitlab_main + + disable_ddl_transaction! + + class Note < MigrationRecord + include EachBatch + + self.table_name = 'notes' + self.inheritance_column = :_type_disabled + end + + def up + queue_background_migration_jobs_by_range_at_intervals( + Note.where(discussion_id: nil), + MIGRATION, + DELAY_INTERVAL, + batch_size: BATCH_SIZE + ) + end + + def down + # no-op + end +end diff --git a/db/schema_migrations/20220420061439 b/db/schema_migrations/20220420061439 new file mode 100644 index 00000000000..cde4753761c --- /dev/null +++ b/db/schema_migrations/20220420061439 @@ -0,0 +1 @@ +02ff5492367d5a0b0f6b1164c33a9fe0475e72b8fba5d2f8affc4c5a118d4192
\ No newline at end of file diff --git a/db/schema_migrations/20220420061450 b/db/schema_migrations/20220420061450 new file mode 100644 index 00000000000..04ee97a7e4d --- /dev/null +++ b/db/schema_migrations/20220420061450 @@ -0,0 +1 @@ +17046780fbe87b7eab87034dfffed239b9da48b5ef78dd1c547575158fc1d37f
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 1a226e1020b..2d052a0a4d0 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -29768,6 +29768,8 @@ CREATE INDEX tmp_index_members_on_state ON members USING btree (state) WHERE (st CREATE INDEX tmp_index_merge_requests_draft_and_status ON merge_requests USING btree (id) WHERE ((draft = false) AND (state_id = 1) AND ((title)::text ~* '^(\[draft\]|\(draft\)|draft:|draft|\[WIP\]|WIP:|WIP)'::text)); +CREATE INDEX tmp_index_notes_on_id_where_discussion_id_is_null ON notes USING btree (id) WHERE (discussion_id IS NULL); + CREATE UNIQUE INDEX tmp_index_on_tmp_project_id_on_namespaces ON namespaces USING btree (tmp_project_id); CREATE INDEX tmp_index_on_vulnerabilities_non_dismissed ON vulnerabilities USING btree (id) WHERE (state <> 2); |