Commit b998f8d
authored
Org slugs: mint at insert, drop lazy minting, make the column NOT NULL (#1006)
The org-slug column was nullable and the runtime self-healed it: every
resolveOrganization (and the SSR gate) lazily minted a slug for any row that
lacked one. That left a permanent nullable state and a heal-on-read cost.
Move slug generation to the single moment a row is inserted — upsertOrganization
mints the slug at INSERT (ON CONFLICT DO NOTHING absorbs the id/slug races,
retrying with a fresh candidate) and keeps the existing slug on conflict. The
three insert sites (createOrganization, acceptInvitation, the WorkOS-fallback
upsert in resolveOrganization) all get a slug for free; resolveOrganization and
the SSR gate's organizationDisplay no longer heal. The schema column is now
NOT NULL (migration 0004), backfilled once for legacy rows.
Deploy order matters and is documented in the backfill script: backfill →
deploy this code → apply 0004. The old code inserts a NULL slug then heals, so
NOT NULL cannot land while it still serves.
Also adds e2e/cloud/auth-routing-flow.test.ts: one browser session walking the
whole arc — signed out → /login → hosted-AuthKit sign-in → org-less onboarding
→ create org → canonical /<slug> dashboard — through the real dev-server SSR
gate. The hops are covered piecewise elsewhere; this is the narrative regression
guard and the only test pinning the bare-/ → /<slug>/ dashboard canonicalization
a fresh login lands on.1 parent 84ad401 commit b998f8d
13 files changed
Lines changed: 1429 additions & 88 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments