diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-22 00:08:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-22 00:08:28 +0300 |
commit | 0a93f691bf210da97fcefe0ddf80b38b0b186a99 (patch) | |
tree | cf17fdecf913d0576a4ec3eba0b3704c06c86470 /db | |
parent | 07d811cd3cf4d3a1802363532756bf69cfc6346f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
9 files changed, 137 insertions, 0 deletions
diff --git a/db/post_migrate/20230419010332_ensure_todos_bigint_backfill_is_finished_for_gitlab_dot_com.rb b/db/post_migrate/20230419010332_ensure_todos_bigint_backfill_is_finished_for_gitlab_dot_com.rb new file mode 100644 index 00000000000..d03fb0100e4 --- /dev/null +++ b/db/post_migrate/20230419010332_ensure_todos_bigint_backfill_is_finished_for_gitlab_dot_com.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class EnsureTodosBigintBackfillIsFinishedForGitlabDotCom < 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: 'todos', + 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/20230419010551_add_index_todos_note_id_convert_to_bigint_for_gitlab_com.rb b/db/post_migrate/20230419010551_add_index_todos_note_id_convert_to_bigint_for_gitlab_com.rb new file mode 100644 index 00000000000..4ac5eeb5a14 --- /dev/null +++ b/db/post_migrate/20230419010551_add_index_todos_note_id_convert_to_bigint_for_gitlab_com.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class AddIndexTodosNoteIdConvertToBigintForGitlabCom < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + TABLE_NAME = :todos + INDEX_NAME = :index_todos_on_note_id_convert_to_bigint + + def up + return unless should_run? + + # This will replace the existing index_todos_on_note_id + add_concurrent_index TABLE_NAME, :note_id_convert_to_bigint, name: INDEX_NAME + 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/20230419012426_add_fk_on_todos_note_id_convert_to_bigint_for_gitlab_com.rb b/db/post_migrate/20230419012426_add_fk_on_todos_note_id_convert_to_bigint_for_gitlab_com.rb new file mode 100644 index 00000000000..0cbab6f93da --- /dev/null +++ b/db/post_migrate/20230419012426_add_fk_on_todos_note_id_convert_to_bigint_for_gitlab_com.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +class AddFkOnTodosNoteIdConvertToBigintForGitlabCom < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + SOURCE_TABLE_NAME = :todos + TARGET_TABLE_NAME = :notes + FK_NAME = :fk_todos_note_id_convert_to_bigint + + def up + return unless should_run? + + # This will replace the existing fk_91d1f47b13 + # 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/20230419012621_async_validate_fk_todos_note_id_convert_to_bigint_for_gitlab_com.rb b/db/post_migrate/20230419012621_async_validate_fk_todos_note_id_convert_to_bigint_for_gitlab_com.rb new file mode 100644 index 00000000000..f7bef55ba01 --- /dev/null +++ b/db/post_migrate/20230419012621_async_validate_fk_todos_note_id_convert_to_bigint_for_gitlab_com.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class AsyncValidateFkTodosNoteIdConvertToBigintForGitlabCom < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + TABLE_NAME = :todos + COLUMN = :note_id_convert_to_bigint + FK_NAME = :fk_todos_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/20230419010332 b/db/schema_migrations/20230419010332 new file mode 100644 index 00000000000..ab1fdc39079 --- /dev/null +++ b/db/schema_migrations/20230419010332 @@ -0,0 +1 @@ +440922ff7763edaa21e1ceaa435929f5c181d25bfd712f9f4b67792cc59d58d6
\ No newline at end of file diff --git a/db/schema_migrations/20230419010551 b/db/schema_migrations/20230419010551 new file mode 100644 index 00000000000..e3bca4b4efa --- /dev/null +++ b/db/schema_migrations/20230419010551 @@ -0,0 +1 @@ +2bf372259e17947046aa63889975a4051395785dfa27092e55f1e3541984fa74
\ No newline at end of file diff --git a/db/schema_migrations/20230419012426 b/db/schema_migrations/20230419012426 new file mode 100644 index 00000000000..335247d13c2 --- /dev/null +++ b/db/schema_migrations/20230419012426 @@ -0,0 +1 @@ +108adc46f0e9e05912325e8fbd7d32d35d80257e55c370d782640c06c7737030
\ No newline at end of file diff --git a/db/schema_migrations/20230419012621 b/db/schema_migrations/20230419012621 new file mode 100644 index 00000000000..de5f54ac3c1 --- /dev/null +++ b/db/schema_migrations/20230419012621 @@ -0,0 +1 @@ +0a8b81bdb20958c543322578cb0955a212319d272338f3064ee8d5a493282c24
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 84183c6720a..ed9fed72760 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -32444,6 +32444,8 @@ CREATE INDEX index_todos_on_group_id ON todos USING btree (group_id); CREATE INDEX index_todos_on_note_id ON todos USING btree (note_id); +CREATE INDEX index_todos_on_note_id_convert_to_bigint ON todos USING btree (note_id_convert_to_bigint); + CREATE INDEX index_todos_on_project_id_and_id ON todos USING btree (project_id, id); CREATE INDEX index_todos_on_target_type_and_target_id ON todos USING btree (target_type, target_id); @@ -37182,6 +37184,9 @@ ALTER TABLE ONLY timelogs ALTER TABLE ONLY timelogs ADD CONSTRAINT fk_timelogs_note_id FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE SET NULL; +ALTER TABLE ONLY todos + ADD CONSTRAINT fk_todos_note_id_convert_to_bigint FOREIGN KEY (note_id_convert_to_bigint) REFERENCES notes(id) ON DELETE CASCADE NOT VALID; + ALTER TABLE ONLY u2f_registrations ADD CONSTRAINT fk_u2f_registrations_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; |