/** Extract the PostgreSQL error code from a raw pg error or a drizzle-wrapped one. */ export function pgCode(e: unknown): string | undefined { const err = e as { code?: string; cause?: { code?: string } } | undefined; return err?.code ?? err?.cause?.code; } export const PG_UNIQUE_VIOLATION = "23505";