@eristack/entity-id
Version:
UUID v7 entity identifiers — sortable, parseable, Drizzle column helper
26 lines (16 loc) • 768 B
Markdown
```bash
pnpm add @eristack/entity-id drizzle-orm
```
```ts
import { entityIdColumn } from "@eristack/entity-id/drizzle";
entityIdColumn("pgsql", "id"); // uuid().$defaultFn(() => generateEntityId()) — app-side default, not DB serial/identity
entityIdColumn("mysql", "id"); // char(36)
entityIdColumn("sqlite", "id"); // text
```
Pass optional `{ sqlName: "partner_id" }` when the property name differs from the SQL column.
Use the same column helper on FK columns **without** `$defaultFn` — only call `parseEntityId` in the app layer before insert.
Postgres: native `uuid` type. Existing v4 columns require a one-time migration strategy in the app — this package does not migrate legacy data.