clear references

This commit is contained in:
2026-05-28 08:59:24 -04:00
parent 1e1773c186
commit 26d9f8b050
12 changed files with 113 additions and 106 deletions

View File

@@ -26,28 +26,28 @@ deliverables:
- RemoveBrokers (InfoBroker, RemovalRequest, BrokerListing)
- `web/src/server/db/schema/` — Optional split directory if single file becomes unwieldy:
- `auth.ts`, `subscription.ts`, `darkwatch.ts`, `voiceprint.ts`, `spamshield.ts`, `alerts.ts`, `correlation.ts`, `reports.ts`, `marketing.ts`, `hometitle.ts`, `removebrokers.ts`
- All enums defined as TypeScript const arrays or Drizzle `pgEnum`
- All enums defined as TypeScript const arrays or Drizzle `enum()`
- All indexes, unique constraints, and foreign keys preserved
- Relations defined using Drizzle's `relations()` helper
steps:
1. Read and analyze `packages/db/prisma/schema.prisma` completely. Document every model, enum, relation, index, and constraint.
2. Install Drizzle ORM and PostgreSQL driver in `web/`:
2. Install Drizzle ORM and Turso client in `web/`:
- `drizzle-orm`
- `pg` (node-postgres) or `@neondatabase/serverless` if using Neon
- `@libsql/client` (Turso/libsql client)
- `drizzle-kit` for migrations
3. Create `web/src/server/db/schema.ts` (or split directory).
4. For each Prisma model, create a Drizzle table definition:
- Map Prisma field types to Drizzle column types:
- `String``varchar`, `text`, `uuid`
- `String``text`, `varchar`
- `Int``integer`
- `Float``real`
- `Boolean``boolean`
- `DateTime``timestamp`
- `Json``jsonb`
- `String[]``text().array()`
- `Boolean``integer` (SQLite has no native boolean, use 0/1)
- `DateTime``text` (ISO strings) or `integer` (Unix timestamp)
- `Json``text` (SQLite stores JSON as text)
- `String[]``text` (serialize to JSON string)
- Preserve `@id`, `@default(uuid())`, `@unique`, `@index`, `@relation`
- Map Prisma enums to Drizzle `pgEnum()`
- Map Prisma enums to Drizzle `enum()` or `text()` with check constraints
5. Define all indexes using Drizzle's `.index()` and `.unique()` on table definitions.
6. Define relations using `relations()` helper for:
- User → accounts, sessions, familyGroups, subscriptions, alerts, voice enrollments, etc.
@@ -77,7 +77,7 @@ validation:
- Run `cd web && npx drizzle-kit generate` and inspect generated SQL
- Compare table count: Prisma schema has X models, Drizzle schema has X tables
- Verify enum values match exactly between Prisma and Drizzle
- Run `npx drizzle-kit push` against a local PostgreSQL instance and confirm all tables are created
- Run `npx drizzle-kit push` against a Turso database (or local SQLite) and confirm all tables are created
notes:
- This is the most critical backend task. A missing field or incorrect relation will cascade into broken tRPC routers.
@@ -85,4 +85,6 @@ notes:
- Prisma's `@updatedAt` auto-timestamp can be replicated with Drizzle's `$onUpdateFn(() => new Date())`.
- Keep the old Prisma schema file as reference until task 41.
- Consider using `drizzle-zod` later (task 11+) to auto-generate validation schemas from Drizzle tables.
- The schema uses PostgreSQL-specific features (arrays, enums, jsonb). Ensure the Drizzle definitions use `pgTable`, `pgEnum`, etc.
- The schema uses SQLite-compatible types. Ensure the Drizzle definitions use `sqliteTable`, `enum()`, etc.
- SQLite stores JSON as text — serialize/deserialize in application code or use Drizzle's `json()` helper.
- SQLite doesn't have native array types — store arrays as JSON-encoded text strings.