diff --git a/db/post_migrate/20240110093654_schedule_index_removal_ci_build_trace_metadata.rb b/db/post_migrate/20240110093654_schedule_index_removal_ci_build_trace_metadata.rb new file mode 100644 index 0000000000000000000000000000000000000000..8f2faa32c818471575baf74d63b89acfb173f2c4 --- /dev/null +++ b/db/post_migrate/20240110093654_schedule_index_removal_ci_build_trace_metadata.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class ScheduleIndexRemovalCiBuildTraceMetadata < Gitlab::Database::Migration[2.2] + milestone '16.8' + disable_ddl_transaction! + + INDEX_NAME = :index_ci_build_trace_metadata_on_trace_artifact_id + TABLE_NAME = :ci_build_trace_metadata + COLUMN_NAME = :trace_artifact_id + + def up + prepare_async_index_removal(TABLE_NAME, COLUMN_NAME, name: INDEX_NAME) + end + + def down + unprepare_async_index(TABLE_NAME, COLUMN_NAME, name: INDEX_NAME) + end +end diff --git a/db/post_migrate/20240110094002_drop_index_from_ci_job_artifact_state.rb b/db/post_migrate/20240110094002_drop_index_from_ci_job_artifact_state.rb new file mode 100644 index 0000000000000000000000000000000000000000..0b92c73ad554b643722dbbe6ccec30448455c2e8 --- /dev/null +++ b/db/post_migrate/20240110094002_drop_index_from_ci_job_artifact_state.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class DropIndexFromCiJobArtifactState < Gitlab::Database::Migration[2.2] + milestone '16.8' + disable_ddl_transaction! + + INDEX_NAME = :index_ci_job_artifact_states_on_job_artifact_id + TABLE_NAME = :ci_job_artifact_states + + def up + remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME) + end + + def down + add_concurrent_index(TABLE_NAME, :job_artifact_id, name: INDEX_NAME) + end +end diff --git a/db/post_migrate/20240110094510_remove_fk_from_ci_job_artifact_state.rb b/db/post_migrate/20240110094510_remove_fk_from_ci_job_artifact_state.rb new file mode 100644 index 0000000000000000000000000000000000000000..bbe1f39e3ede50af81fceec6224fb504a1a53fce --- /dev/null +++ b/db/post_migrate/20240110094510_remove_fk_from_ci_job_artifact_state.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class RemoveFkFromCiJobArtifactState < Gitlab::Database::Migration[2.2] + milestone '16.8' + disable_ddl_transaction! + + SOURCE_TABLE_NAME = :ci_job_artifact_states + TARGET_TABLE_NAME = :ci_job_artifacts + COLUMN = :job_artifact_id + TARGET_COLUMN = :id + FK_NAME = :fk_rails_80a9cba3b2 + + 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/20240110093654 b/db/schema_migrations/20240110093654 new file mode 100644 index 0000000000000000000000000000000000000000..1c5f4a1208ddfdf208c44d763436e8eb3509a0a8 --- /dev/null +++ b/db/schema_migrations/20240110093654 @@ -0,0 +1 @@ +41964f40e257d2d7fb0427f7f2911ea0857d67f51e9a1f4ed26d36d42394dd19 \ No newline at end of file diff --git a/db/schema_migrations/20240110094002 b/db/schema_migrations/20240110094002 new file mode 100644 index 0000000000000000000000000000000000000000..5b6fcb1080abbac0d6453dd261195fde75eed086 --- /dev/null +++ b/db/schema_migrations/20240110094002 @@ -0,0 +1 @@ +ec56796b8c3514380e716259119e7def5a958e7bfade25c69e3c99ffd52a265f \ No newline at end of file diff --git a/db/schema_migrations/20240110094510 b/db/schema_migrations/20240110094510 new file mode 100644 index 0000000000000000000000000000000000000000..e533dc389122a3c7386759fe3deb931c74ed907b --- /dev/null +++ b/db/schema_migrations/20240110094510 @@ -0,0 +1 @@ +6ed6cfa3e8b8b8fdbfacadcdff55dda07365f113d4f84e33c6bab878352cda11 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index bd165b967995db96e3b2e50d05bc0b8a4148fa91..98d6e5d77a679a5a0512d0826c5b195b26143f7b 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -32854,8 +32854,6 @@ CREATE UNIQUE INDEX index_ci_group_variables_on_group_id_and_key_and_environment CREATE UNIQUE INDEX index_ci_instance_variables_on_key ON ci_instance_variables USING btree (key); -CREATE INDEX index_ci_job_artifact_states_on_job_artifact_id ON ci_job_artifact_states USING btree (job_artifact_id); - CREATE INDEX index_ci_job_artifact_states_on_job_artifact_id_partition_id ON ci_job_artifact_states USING btree (job_artifact_id, partition_id); CREATE INDEX index_ci_job_artifacts_expire_at_unlocked_non_trace ON ci_job_artifacts USING btree (expire_at) WHERE ((locked = 0) AND (file_type <> 3) AND (expire_at IS NOT NULL)); @@ -40087,9 +40085,6 @@ ALTER TABLE ONLY clusters_kubernetes_namespaces ALTER TABLE ONLY dependency_proxy_manifest_states ADD CONSTRAINT fk_rails_806cf07a3c FOREIGN KEY (dependency_proxy_manifest_id) REFERENCES dependency_proxy_manifests(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_job_artifact_states - ADD CONSTRAINT fk_rails_80a9cba3b2 FOREIGN KEY (job_artifact_id) REFERENCES ci_job_artifacts(id) ON DELETE CASCADE; - ALTER TABLE ONLY ci_job_artifact_states ADD CONSTRAINT fk_rails_80a9cba3b2_p FOREIGN KEY (partition_id, job_artifact_id) REFERENCES ci_job_artifacts(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE; diff --git a/spec/support/helpers/database/duplicate_indexes.yml b/spec/support/helpers/database/duplicate_indexes.yml index acfda313020a791e28d73269e5684d5d086dceda..80d409f233def246f593af829f1690d168140cc2 100644 --- a/spec/support/helpers/database/duplicate_indexes.yml +++ b/spec/support/helpers/database/duplicate_indexes.yml @@ -37,9 +37,6 @@ ci_job_artifacts: - index_ci_job_artifacts_on_project_id index_ci_job_artifacts_on_project_id_and_id: - index_ci_job_artifacts_on_project_id -ci_job_artifact_states: - index_ci_job_artifact_states_on_job_artifact_id: - - index_ci_job_artifact_states_on_job_artifact_id_partition_id ci_pipeline_artifacts: index_ci_pipeline_artifacts_on_pipeline_id_and_file_type: - index_ci_pipeline_artifacts_on_pipeline_id