[go: up one dir, main page]

Skip to content

Draft: Backfill project_authorizations_for_migrations table

What does this MR do and why?

Backfills the project_authorizations_for_migrations table introduced by !190374 (merged).

We need to restore a deleted unique index on project_authorizations over (project_id, user_id) (#418205). To do so, first we need to deduplicate the table since some installations may contain multiple rows per (project_id, user_id) combination with differing access levels. To deduplicate the table, we create the temporary project_authorizations_for_migrations which we will later swap-rename to project_authorizations.

In !190374 (merged) we already added triggers on project_authorizations to forward writes to project_authorizations_for_migrations.

References

How to set up and validate locally

  1. Queue the background migration:

    bin/rails db:migrate:redo:main RAILS_ENV=development VERSION=20250507144731
  2. Write a duplicate (user_id, project_id) row to project_authorizations with two differing access levels

  3. Finalize the background migration:

    bin/rake gitlab:background_migrations:finalize[MigrateProjectAuthorizations,project_authorizations,id,'[]']
  4. Verify the row in project_authorizations_for_migration has the lower access level

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #525999

Edited by Dominic Bauer

Merge request reports

Loading