Add a unique index on project ID to the Geo project_registry table
The following discussion from !2807 (merged) should be addressed:
-
@nick.thomas started a discussion: So this ensures idempotency if we run the event twice, as long as there's only one log_cursor running.
Unfortunately, it doesn't look like the
geo_project_repository
table has a unique index on project_id, so if two processes somehow ended up running in parallel then we'd get multiple entries for the same project which, I'm assuming, would be bad.Let's deal with this in a separate issue since the other events have the same problem.
This table exists in the database for the Geo secondaries, and as far as I can tell it would be an error for multiple rows to have the same project_id. We don't enforce this constraint at database or rails level though, so there are a number of ways this could happen.
Let's just turn the index into a unique index.
If there are any existing rows that violate the constraint, what is safe to do with them?