Add a migration to fix sequence ownership for CI builds migration

What does this MR do and why?

This backports !160139 (diffs) to 17-2-stable-ee.

GitLab 17.2 shipped a migration (!158711 (merged)) that dropped p_ci_builds.id. However, we received a number of reports of users who had unrelated sequences owned by p_ci_builds.id, so the migration failed because the objects depended on that column existing.

To allow migrations to go through, scan the system catalog for all sequences owned by either p_ci_builds or ci_builds. Generate the ALTER SEQUENCE statement to update the ownership of the sequence based on the expected owners from db/structure.sql.

Note that we could run all 600+ ALTER SEQUENCE commands to bring the database to a consistent state, but to minimize risk we target only on the ones to allow the CI builds migration to proceed.

Relates to #468541 (closed)

MR acceptance checklist

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

  • This MR is backporting a bug fix, documentation update, or spec fix, previously merged in the default branch.
  • The MR that fixed the bug on the default branch has been deployed to GitLab.com (not applicable for documentation or spec changes).
  • This MR has a severity label assigned (if applicable).
  • Set the milestone of the merge request to match the target backport branch version.
  • This MR has been approved by a maintainer (only one approval is required).
  • Ensure the e2e:package-and-test-ee job has either succeeded or been approved by a Software Engineer in Test.

Note to the merge request author and maintainer

If you have questions about the patch release process, please:

Edited by Stan Hu

Merge request reports

Loading