Skip to content

Replace foreign keys to use the partitioned table - 5

Marius Bobin requested to merge 414396-partitioned-fks-v6 into master

What does this MR do and why?

Replace foreign keys to use the partitioned table - 5

This reintroduces one of the migrations from !123811 (merged) because it failed to get the locks due to locking order issues.

Changelog: other

Screenshots or screen recordings

RAILS_ENV=test pgai use -o ci bin/rails db:migrate:ci

ci: == 20230627115305 ReplacePCiBuildsMetadataForeignKeyV4: migrating =============
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- execute("LOCK TABLE ci_builds, p_ci_builds, p_ci_builds_metadata IN ACCESS EXCLUSIVE MODE;\n\nALTER TABLE p_ci_builds_metadata\n  ADD CONSTRAINT temp_fk_e20479742e_p\n  FOREIGN KEY (partition_id, build_id)\n  REFERENCES p_ci_builds (partition_id, id)\n  ON  UPDATE CASCADE ON DELETE CASCADE;\n")
ci:    -> 0.2207s
ci: == 20230627115305 ReplacePCiBuildsMetadataForeignKeyV4: migrated (2.3848s) ====

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #414396 (closed)

Edited by Marius Bobin

Merge request reports