Bigint migration for deployment_clusters fails due to missing unique constraint on deployments.id_convert_to_bigint
Summary
The migration 20251222180619_add_bigint_fk_for_deployment_clusters.rb introduced in !213446 (merged) fails with the following error:
PG::InvalidForeignKey: ERROR: there is no unique constraint matching given keys for referenced table "deployments"Details
The migration attempts to create a foreign key from deployment_clusters.deployment_id_convert_to_bigint to deployments.id_convert_to_bigint, but the deployments table does not have a unique constraint on id_convert_to_bigint - only on id (the primary key).
The foreign key definition in the migration:
{
source_table: :deployment_clusters,
column: :deployment_id_convert_to_bigint,
target_table: :deployments,
target_column: :id_convert_to_bigint, # <-- Should be :id
on_delete: :cascade,
tmp_name: :fk_rails_6359a164df_tmp
}Impact
- Reconfigure on dev instance failed
- This would have failed while running PDM on staging and production instances
Related
- Caused by: !213446 (merged)
- Incident: gitlab-com/gl-infra/production#21036
Edited by 🤖 GitLab Bot 🤖