diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-21 06:07:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-21 06:07:54 +0000 |
commit | 6c3db3c7e44f428675da5e85ef1244a35125940e (patch) | |
tree | edcd626bbcf4ecb2676f990458ecaadbf9455b1e /db | |
parent | bfb5557b15d66fc1c22aeec5c345241946b103a3 (diff) | |
download | gitlab-ce-6c3db3c7e44f428675da5e85ef1244a35125940e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
5 files changed, 53 insertions, 4 deletions
diff --git a/db/post_migrate/20230218152729_validate_fk_on_ci_job_artifacts_partition_id_and_job_id.rb b/db/post_migrate/20230218152729_validate_fk_on_ci_job_artifacts_partition_id_and_job_id.rb new file mode 100644 index 00000000000..9a9cb0d9487 --- /dev/null +++ b/db/post_migrate/20230218152729_validate_fk_on_ci_job_artifacts_partition_id_and_job_id.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class ValidateFkOnCiJobArtifactsPartitionIdAndJobId < Gitlab::Database::Migration[2.1] + TABLE_NAME = :ci_job_artifacts + FK_NAME = :fk_rails_c5137cb2c1_p + COLUMNS = [:partition_id, :job_id] + + def up + validate_foreign_key(TABLE_NAME, COLUMNS, name: FK_NAME) + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20230218152730_remove_fk_to_ci_builds_ci_job_artifacts_on_job_id.rb b/db/post_migrate/20230218152730_remove_fk_to_ci_builds_ci_job_artifacts_on_job_id.rb new file mode 100644 index 00000000000..02747d57eab --- /dev/null +++ b/db/post_migrate/20230218152730_remove_fk_to_ci_builds_ci_job_artifacts_on_job_id.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +class RemoveFkToCiBuildsCiJobArtifactsOnJobId < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + SOURCE_TABLE_NAME = :ci_job_artifacts + TARGET_TABLE_NAME = :ci_builds + COLUMN = :job_id + TARGET_COLUMN = :id + FK_NAME = :fk_rails_c5137cb2c1 + + def up + with_lock_retries do + remove_foreign_key_if_exists( + SOURCE_TABLE_NAME, + TARGET_TABLE_NAME, + name: FK_NAME, + reverse_lock_order: true + ) + end + end + + def down + add_concurrent_foreign_key( + SOURCE_TABLE_NAME, + TARGET_TABLE_NAME, + column: COLUMN, + target_column: TARGET_COLUMN, + validate: true, + reverse_lock_order: true, + on_delete: :cascade, + name: FK_NAME + ) + end +end diff --git a/db/schema_migrations/20230218152729 b/db/schema_migrations/20230218152729 new file mode 100644 index 00000000000..f78be055435 --- /dev/null +++ b/db/schema_migrations/20230218152729 @@ -0,0 +1 @@ +ac404c1dd1b2a38b8d02563b4b9306076f35120448d78b130c0421364c11822c
\ No newline at end of file diff --git a/db/schema_migrations/20230218152730 b/db/schema_migrations/20230218152730 new file mode 100644 index 00000000000..55fb6069403 --- /dev/null +++ b/db/schema_migrations/20230218152730 @@ -0,0 +1 @@ +f85595c6176426369f8558ba3dadf6ee2a5efa17f2d304dc8397862fc7d52545
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 2eddcb57bdc..a732006ceb8 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -36135,10 +36135,7 @@ ALTER TABLE ONLY boards_epic_board_recent_visits ADD CONSTRAINT fk_rails_c4dcba4a3e FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; ALTER TABLE ONLY ci_job_artifacts - ADD CONSTRAINT fk_rails_c5137cb2c1 FOREIGN KEY (job_id) REFERENCES ci_builds(id) ON DELETE CASCADE; - -ALTER TABLE ONLY ci_job_artifacts - ADD CONSTRAINT fk_rails_c5137cb2c1_p FOREIGN KEY (partition_id, job_id) REFERENCES ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID; + ADD CONSTRAINT fk_rails_c5137cb2c1_p FOREIGN KEY (partition_id, job_id) REFERENCES ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE; ALTER TABLE ONLY packages_events ADD CONSTRAINT fk_rails_c6c20d0094 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE SET NULL; |