Fix teams_name_unique constraint for Hasura on_conflict#33
Merged
Conversation
Migration 1709836800001 created an expression index on lower(trim(name))
which cannot be used as a Hasura on_conflict constraint target. This broke
team auto-provisioning (dataSourceHelpers.js) because the insert mutation
uses on_conflict: { constraint: teams_name_unique }. Application code
already normalizes names to lowercase/trimmed before insert, so a plain
unique constraint is sufficient and Hasura-compatible.
Also increases hasura_cli migrations server timeout from 30s to 120s to
prevent restart loops when applying large migration sets on cold start.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
yasirali179
approved these changes
Mar 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
1741520400001: Replaces the expression indexlower(trim(name))onteamswith a plainUNIQUEconstraint. The expression index (from migration1709836800001) cannot be used as a Hasuraon_conflicttarget, which broke team auto-provisioning indataSourceHelpers.js. Application code already normalizes names tolower(trim())before insert, so a plain constraint is sufficient.hasura_climigrations server timeout from 30s → 120s to prevent restart loops when applying large migration sets on cold start.Context
This was discovered as a cluster incident requiring manual DDL fixes. The expression index silently broke the
insert_teams_one(..., on_conflict: { constraint: teams_name_unique })mutation — Hasura requires an actual constraint, not an expression index, foron_conflicttargets.Cluster fixes this prevents from recurring
external: truepatchesTest plan
pg_constraintshowsteams_name_uniqueas typeu(unique constraint)insert_teams_onewithon_conflict: { constraint: teams_name_unique }— returnsnull(no-op) for existing team, no errorhasura_clistarts and reaches healthy state with the timeout increase🤖 Generated with Claude Code