You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: add organization_id IS NOT NULL to unique index WHERE clause
NULL values are treated as distinct in PostgreSQL unique indexes, so the
pending invite uniqueness constraint was ineffective for orphaned rows
after ON DELETE SET NULL.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: server/migrations/20260129231659_team-invites.sql
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,6 @@ CREATE TABLE "team_invites" (
19
19
CONSTRAINT"team_invites_token_check"CHECK ((token <>''::text) AND (char_length(token) <=64))
20
20
);
21
21
-- Create index "team_invites_organization_id_email_pending_key" to table: "team_invites"
22
-
CREATEUNIQUE INDEX "team_invites_organization_id_email_pending_key" ON"team_invites" ("organization_id", "email") WHERE ((deleted IS FALSE) AND (status ='pending'::text));
22
+
CREATEUNIQUE INDEX "team_invites_organization_id_email_pending_key" ON"team_invites" ("organization_id", "email") WHERE ((deleted IS FALSE) AND (status ='pending'::text)AND (organization_id IS NOT NULL));
23
23
-- Create index "team_invites_token_key" to table: "team_invites"
24
24
CREATEUNIQUE INDEX "team_invites_token_key" ON"team_invites" ("token") WHERE (deleted IS FALSE);
0 commit comments