1---2name: data3description: Data — Index4---56# Data — Index78Persimmon data = PostgreSQL with `pgvector`, accessed through Prisma with one shared client. This mother is a map; follow the child for the actual work.910## Trigger1112- "Design the schema for…" / "Add a Prisma model / migration"13- "Store embeddings" / "vector column" / "pgvector"14- "Search by similarity" / "HNSW index"1516## The child skills1718| Skill | When to use | Owns |19|---|---|---|20| `data-prisma-pgvector` | Any schema design, migration, vector column, or similarity query | Prisma schema patterns, pgvector extension setup, HNSW indexing (`vector_cosine_ops`), cosine-similarity queries, the one-shared-client rule |21| `data-schema-design` | Modeling rigor before a schema is final | Snapshot-mutable-values, lifecycle enums, join models, FK/cardinality, the validation lenses |22| `data-booking-availability` | Reservations / slots / availability | Slot schema, availability queries, blackout/lead-time, waitlist, deposits |23| `data-db-cli` | Inspect or query the live DB without writing a script | The read-only-by-default `db` CLI (`npm run db`) + Postgres MCP setup, the `--write`/`--prod` safety gates |2425## Persimmon data defaults — one-screen summary2627- **One Prisma client** in `src/lib/db.ts`. Never instantiate `PrismaClient` elsewhere.28- **Migrations**: `prisma migrate dev` locally. On Railway, apply via `prisma db push` in the build step OR a migrate-deploy job — pick one per project and stick with it.29- **After `db push` with enum/model changes**: restart the dev server (the running Prisma client is stale).30- **pgvector index**: HNSW beats IVFFlat for recall + latency under ~10M rows. Build with `CREATE INDEX ... USING hnsw (embedding vector_cosine_ops)`.31- **Never query a filtered-subset HNSW index without the filter.**32- **Naming**: models `PascalCase` singular; fields `camelCase`; `createdAt`/`updatedAt` on every model; Postgres enums, not string constants.3334## Anti-patterns banned3536- Instantiating `PrismaClient` outside `src/lib/db.ts`37- Mixing `migrate` and `db push` strategies in one project38- Unfiltered queries against a filtered-subset vector index39- String constants where a Postgres enum belongs4041## Relationship to other mothers4243| Mother | Connection |44|---|---|45| `ai` | `ai-rag-retrieval` stores/searches embeddings here |46| `stack` | Server Actions read/write through the shared Prisma client |47| `quality` | N+1, unbounded lists, missing indexes flagged by `quality-review-data-layer` |