mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 05:53:43 +00:00
It turns out that for some some deployments, there exists a second, duplicate, foreign key constraint for user_profile_id. The logic below would try to rename both to the same name, which would fail on the second: ``` psycopg2.errors.DuplicateObject: constraint "zerver_userpresenceo_user_profile_id_d75366d6_fk_zerver_us" for relation "zerver_userpresence" already exists ``` Eliminate the duplicate constraint, rather than attempting to rename it. Also add a block, in case of future reuse of this pattern, which caveats that this approach will not work in the presence of explicitly-named indexes. UserPresence happens to not have any, so this technique is safe in this instance. Co-authored-by: Alex Vandiver <alexmv@zulip.com>