diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-19 03:08:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-19 03:08:30 +0300 |
commit | 8c80b21468c5c969644c9ea83fec7b43dba1eb3c (patch) | |
tree | efdc69f22231ae472f0264dee21001e595c4f86d /db | |
parent | a407a618ae21dce15c85ae15c465a531811a69b9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
11 files changed, 154 insertions, 2 deletions
diff --git a/db/post_migrate/20230412013251_ensure_system_note_metadata_bigint_backfill_is_finished_for_gitlab_dot_com.rb b/db/post_migrate/20230412013251_ensure_system_note_metadata_bigint_backfill_is_finished_for_gitlab_dot_com.rb new file mode 100644 index 00000000000..a4ae604d66d --- /dev/null +++ b/db/post_migrate/20230412013251_ensure_system_note_metadata_bigint_backfill_is_finished_for_gitlab_dot_com.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class EnsureSystemNoteMetadataBigintBackfillIsFinishedForGitlabDotCom < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + def up + return unless should_run? + + ensure_batched_background_migration_is_finished( + job_class_name: 'CopyColumnUsingBackgroundMigrationJob', + table_name: 'system_note_metadata', + column_name: 'id', + job_arguments: [['note_id'], ['note_id_convert_to_bigint']] + ) + end + + def down + # no-op + end + + private + + def should_run? + com_or_dev_or_test_but_not_jh? + end +end diff --git a/db/post_migrate/20230413012807_remove_index_sync_index_on_merge_requests_on_state_id_and_merge_status.rb b/db/post_migrate/20230413012807_remove_index_sync_index_on_merge_requests_on_state_id_and_merge_status.rb new file mode 100644 index 00000000000..664657015a7 --- /dev/null +++ b/db/post_migrate/20230413012807_remove_index_sync_index_on_merge_requests_on_state_id_and_merge_status.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemoveIndexSyncIndexOnMergeRequestsOnStateIdAndMergeStatus < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name :merge_requests, name: 'idx_merge_requests_on_state_id_and_merge_status' + end + + def down + add_concurrent_index :merge_requests, [:state_id, :merge_status], + where: "((state_id = 1) AND ((merge_status)::text = 'can_be_merged'::text))", + name: 'idx_merge_requests_on_state_id_and_merge_status' + end +end diff --git a/db/post_migrate/20230413041918_add_unique_index_system_note_metadata_note_id_convert_to_bigint_for_gitlab_com.rb b/db/post_migrate/20230413041918_add_unique_index_system_note_metadata_note_id_convert_to_bigint_for_gitlab_com.rb new file mode 100644 index 00000000000..b8ee6285a33 --- /dev/null +++ b/db/post_migrate/20230413041918_add_unique_index_system_note_metadata_note_id_convert_to_bigint_for_gitlab_com.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class AddUniqueIndexSystemNoteMetadataNoteIdConvertToBigintForGitlabCom < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + TABLE_NAME = :system_note_metadata + INDEX_NAME = :index_system_note_metadata_on_note_id_convert_to_bigint + + def up + return unless should_run? + + # This will replace the existing index_system_note_metadata_on_note_id + add_concurrent_index TABLE_NAME, :note_id_convert_to_bigint, unique: true, + name: 'index_system_note_metadata_on_note_id_convert_to_bigint' + end + + def down + return unless should_run? + + remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) + end + + private + + def should_run? + com_or_dev_or_test_but_not_jh? + end +end diff --git a/db/post_migrate/20230413041919_add_fk_on_system_note_metadata_note_id_convert_to_bigint_for_gitlab_com.rb b/db/post_migrate/20230413041919_add_fk_on_system_note_metadata_note_id_convert_to_bigint_for_gitlab_com.rb new file mode 100644 index 00000000000..59ea8ca3c7f --- /dev/null +++ b/db/post_migrate/20230413041919_add_fk_on_system_note_metadata_note_id_convert_to_bigint_for_gitlab_com.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +class AddFkOnSystemNoteMetadataNoteIdConvertToBigintForGitlabCom < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + SOURCE_TABLE_NAME = :system_note_metadata + TARGET_TABLE_NAME = :notes + FK_NAME = :fk_system_note_metadata_note_id_convert_to_bigint + + def up + return unless should_run? + + # This will replace the existing fk_d83a918cb1 + # when we swap the integer and bigint columns + add_concurrent_foreign_key SOURCE_TABLE_NAME, TARGET_TABLE_NAME, + column: :note_id_convert_to_bigint, + name: FK_NAME, + on_delete: :cascade, + reverse_lock_order: true, + validate: false + end + + def down + return unless should_run? + + with_lock_retries do + remove_foreign_key_if_exists( + SOURCE_TABLE_NAME, + TARGET_TABLE_NAME, + name: FK_NAME, + reverse_lock_order: true + ) + end + end + + private + + def should_run? + com_or_dev_or_test_but_not_jh? + end +end diff --git a/db/post_migrate/20230413041920_async_validate_fk_system_note_metadata_note_id_convert_to_bigint_for_gitlab_com.rb b/db/post_migrate/20230413041920_async_validate_fk_system_note_metadata_note_id_convert_to_bigint_for_gitlab_com.rb new file mode 100644 index 00000000000..bba0f09dd78 --- /dev/null +++ b/db/post_migrate/20230413041920_async_validate_fk_system_note_metadata_note_id_convert_to_bigint_for_gitlab_com.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class AsyncValidateFkSystemNoteMetadataNoteIdConvertToBigintForGitlabCom < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + TABLE_NAME = :system_note_metadata + COLUMN = :note_id_convert_to_bigint + FK_NAME = :fk_system_note_metadata_note_id_convert_to_bigint + + def up + return unless should_run? + + prepare_async_foreign_key_validation TABLE_NAME, COLUMN, name: FK_NAME + end + + def down + return unless should_run? + + unprepare_async_foreign_key_validation TABLE_NAME, COLUMN, name: FK_NAME + end + + private + + def should_run? + com_or_dev_or_test_but_not_jh? + end +end diff --git a/db/schema_migrations/20230412013251 b/db/schema_migrations/20230412013251 new file mode 100644 index 00000000000..82f226a482d --- /dev/null +++ b/db/schema_migrations/20230412013251 @@ -0,0 +1 @@ +d81ed136179bbc28a6b8048de34674ced7c0ffa891a0045b108f891979bbc46c
\ No newline at end of file diff --git a/db/schema_migrations/20230413012807 b/db/schema_migrations/20230413012807 new file mode 100644 index 00000000000..bfb25c1bc63 --- /dev/null +++ b/db/schema_migrations/20230413012807 @@ -0,0 +1 @@ +7bf75dca15fcf1a73a9d201968ab85eb18983d1921a5bf7d0661083137de40c9
\ No newline at end of file diff --git a/db/schema_migrations/20230413041918 b/db/schema_migrations/20230413041918 new file mode 100644 index 00000000000..373b9cfa66a --- /dev/null +++ b/db/schema_migrations/20230413041918 @@ -0,0 +1 @@ +86b631d6511154139835d508b4f694c604b0d6c12d553d107e4c206f034b8453
\ No newline at end of file diff --git a/db/schema_migrations/20230413041919 b/db/schema_migrations/20230413041919 new file mode 100644 index 00000000000..6376268aaab --- /dev/null +++ b/db/schema_migrations/20230413041919 @@ -0,0 +1 @@ +8e05119e15d3a547db7844697ae5cbfc4760a4f329320acc8519a3ba9271ff29
\ No newline at end of file diff --git a/db/schema_migrations/20230413041920 b/db/schema_migrations/20230413041920 new file mode 100644 index 00000000000..c2f9dd23919 --- /dev/null +++ b/db/schema_migrations/20230413041920 @@ -0,0 +1 @@ +aebd6315b218f36b524d856dee5ce82d838693f689124b181fa6242dda1f80fc
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 4bcfaeb067c..b08065a5cd4 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -29348,8 +29348,6 @@ CREATE INDEX idx_merge_requests_on_merged_state ON merge_requests USING btree (i CREATE INDEX idx_merge_requests_on_source_project_and_branch_state_opened ON merge_requests USING btree (source_project_id, source_branch) WHERE (state_id = 1); -CREATE INDEX idx_merge_requests_on_state_id_and_merge_status ON merge_requests USING btree (state_id, merge_status) WHERE ((state_id = 1) AND ((merge_status)::text = 'can_be_merged'::text)); - CREATE INDEX idx_merge_requests_on_target_project_id_and_iid_opened ON merge_requests USING btree (target_project_id, iid) WHERE (state_id = 1); CREATE INDEX idx_merge_requests_on_target_project_id_and_locked_state ON merge_requests USING btree (target_project_id) WHERE (state_id = 4); @@ -32356,6 +32354,8 @@ CREATE UNIQUE INDEX index_system_note_metadata_on_description_version_id ON syst CREATE UNIQUE INDEX index_system_note_metadata_on_note_id ON system_note_metadata USING btree (note_id); +CREATE UNIQUE INDEX index_system_note_metadata_on_note_id_convert_to_bigint ON system_note_metadata USING btree (note_id_convert_to_bigint); + CREATE INDEX index_taggings_on_tag_id ON taggings USING btree (tag_id); CREATE INDEX index_taggings_on_taggable_id_and_taggable_type_and_context ON taggings USING btree (taggable_id, taggable_type, context); @@ -37142,6 +37142,9 @@ ALTER TABLE ONLY integrations ALTER TABLE ONLY merge_requests ADD CONSTRAINT fk_source_project FOREIGN KEY (source_project_id) REFERENCES projects(id) ON DELETE SET NULL; +ALTER TABLE ONLY system_note_metadata + ADD CONSTRAINT fk_system_note_metadata_note_id_convert_to_bigint FOREIGN KEY (note_id_convert_to_bigint) REFERENCES notes(id) ON DELETE CASCADE NOT VALID; + ALTER TABLE ONLY timelogs ADD CONSTRAINT fk_timelogs_issues_issue_id FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE; |