SKILL.md
Source of Truth
- Schema:
apps/backend/prisma/schema.prisma. - Prisma config:
apps/backend/prisma.config.ts. - Scoped services:
apps/backend/src/prisma/services/.
Current schema is large: 200+ models and 140+ enums. Do not duplicate exhaustive model lists in skills; inspect the schema before editing.
Prisma 7 Datasource
schema.prisma declares provider/generator. The database URL is not in the schema; it is provided through apps/backend/prisma.config.ts.
// prisma.config.ts
export default defineConfig({
datasource: { url: process.env.DATABASE_URL! },
});
Naming
- Models are generally
snakecase:users,storeusers,subscription_plans. - Fields are generally
snake_case, but exceptions exist. Preserve existing naming in the touched model. - Enum names are generally snakecase, often with
enum, but enum values are mixed lower/upper case. - TypeScript variables should stay camelCase unless mapping directly to Prisma field names.
Schema Editing Workflow
- Load relevant domain skills and
vendix-prisma-migrations. - Edit
schema.prismaminimally. - Create migration with backend workspace command or
prisma migrate dev --create-onlywhen SQL needs review first. - Review generated SQL for enum, data, FK, index, and destructive risks.
- Register new models in scoped Prisma services before writing service logic.
- Regenerate client if needed.
Preferred commands:
npm run db:migrate:dev -w apps/backend
npm run prisma:generate -w apps/backend
Relationship And Index Rules
- Add indexes for foreign keys and common tenant filters.
- Multi-tenant models usually need
organizationid,storeid, or a relation to a scoped parent. - If a model is accessed through
StorePrismaService,OrganizationPrismaService, orEcommercePrismaService, update the scoped service registration. - For pgvector fields, Prisma uses
Unsupported("vector(1536)"); vector operations use raw SQL.
Migration Notes
- Adding enum values must be idempotent:
ALTER TYPE ... ADD VALUE IF NOT EXISTSor guardedDO $$. - If new enum values are used in data updates, split migrations when Postgres requires it.
- Do not drop columns/tables or mutate data without explicit approval and
DATA IMPACTheader.
Related Skills
vendix-prisma-migrationsvendix-prisma-scopesvendix-prisma-seedvendix-naming-conventions