(id: string, name: string, slug: string)
| 39 | // null when either conflict swallowed the insert — the caller decides whether |
| 40 | // to re-read (id race) or retry with a new candidate (slug race). |
| 41 | const tryInsertOrg = async (id: string, name: string, slug: string) => { |
| 42 | const [row] = await db |
| 43 | .insert(organizations) |
| 44 | .values({ id, name, slug }) |
| 45 | .onConflictDoNothing() |
| 46 | .returning(); |
| 47 | return row ?? null; |
| 48 | }; |
| 49 | |
| 50 | // Every new org row is born with a slug — there is no nullable window and no |
| 51 | // self-healing. Existing rows keep their slug (stable across renames, so org |
no test coverage detected