PhoenixKit 2.22.3: No more duplicate user connections
PhoenixKit 2.22.3 fixes duplicate connections between users.
The checks against duplicate connections, follows and blocks relied on database indexes that were never created. Two users who clicked “connect” on each other at the same moment could both get through, leaving two rows for one relationship. That could turn into a pending request between users who were already connected, or an error when the connection was looked up. Migration V188 removes such duplicates, keeping an accepted connection over a pending one, and adds the three missing indexes.
The release also adds PhoenixKit.TestSupport.PostgresPreflight, a database connection check for module test suites. It is not meant for application code.
Upgrading
Run mix phoenix_kit.update to apply migration V188.
Full release notes: PhoenixKit 2.22.3
2.22.3 · 8 September 2026
Added
PhoenixKit.TestSupport.PostgresPreflight— a shared, classified PostgreSQL connection check for a package’stest_helper.exs. Replaces thepsql -lqtlisting that ran as the shell user over a unix socket and answered the wrong question: it said nothing about whether the configured role could reach the database over TCP, so a wrongPGUSERdid not surface as “wrongPGUSER” — it queued through the SQL sandbox and died minutes later as a pool-checkout timeout that read like a flaky test. Ships inlib/(nottest/support/) so sibling packages depending onphoenix_kitthrough Hex can call it too; never call it from application code.
Fixed
phoenix_kit_user_connections’ threeunique_constraint/3declarations were inert.phoenix_kit_user_follows_unique_idx,phoenix_kit_user_blocks_unique_idxandphoenix_kit_user_connections_requester_recipient_uidxhave always been named in the module’s schemas, but the indexes backing them never existed — a database violation is whatunique_constraint/3translates into a changeset error, and with no index there was no violation. Two users clicking “connect” on each other at the same moment both passedrequest_connection/2’s read-then-write pre-check and both inserted, leaving a duplicate relationship that a later auto-accept could turn into a live pending request between two already-connected users, or into two “accepted” rows that madeget_accepted_connection/2raiseEcto.MultipleResultsError. V188 removes any duplicates the race already produced (favoring an accepted row over a pending one) and creates the three indexes — an expression index onLEAST/GREATESTof the pair for the undirectedphoenix_kit_user_connectionstable, ordered-pair indexes for the directed follows/blocks tables — so the existingunique_constraint/3calls start enforcing what they always claimed to.
PhoenixKit 2.22.3. Install or update: {:phoenix_kit, "~> 2.22"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.