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
-
Queue the background migration:
bin/rails db:migrate:redo:main RAILS_ENV=development VERSION=20250507144731 -
Write a duplicate
(user_id, project_id)row toproject_authorizationswith two differing access levels -
Finalize the background migration:
bin/rake gitlab:background_migrations:finalize[MigrateProjectAuthorizations,project_authorizations,id,'[]'] -
Verify the row in
project_authorizations_for_migrationhas 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