Database Migrations
Strata uses Prisma Migrate for database schema management.
Schema Location
Section titled “Schema Location”The Prisma schema is at backend/prisma/schema.prisma. It defines all models, relations, and indexes.
Current Migration History
Section titled “Current Migration History”The init migration creates the original accounting schema. Later migrations add schema changes, including 20260928120000_financing_scenarios, which adds the standalone financing_scenarios table. There is no portfolio table — the schema never had one. Both PortfolioSnapshot and FinancingScenario are standalone records without accounting foreign keys.
Common Commands
Section titled “Common Commands”All commands run from backend/:
# Apply pending migrations (production/CI)npx prisma migrate deploy
# Create a new migration after schema changes (development)npx prisma migrate dev --name describe_your_change
# Reset database (drops + re-creates + seeds)npx prisma migrate reset
# Generate Prisma Client (after schema changes)npx prisma generate
# Seed the databasenpx prisma db seed
# Open Prisma Studio (visual DB editor)npx prisma studioWorkflow
Section titled “Workflow”- Edit
prisma/schema.prisma - Run
npx prisma migrate dev --name your_change - Prisma generates a SQL migration in
prisma/migrations/ - Review the generated SQL
- Commit both the schema and migration files
Seed Data
Section titled “Seed Data”The seed entrypoint is backend/prisma/seed.ts, which dispatches by profile:
- Development profile (
STRATA_SEED_PROFILE=development, default fallback):- 13 asset types
- hierarchical categories
- tags
- demo assets
- seeded snapshot history
- Production profile (
STRATA_SEED_PROFILE=production):- 13 asset types
- hierarchical categories
- no demo assets/tags/snapshots
Run with:
npx prisma db seed# Optional explicit override:STRATA_SEED_PROFILE=production npx prisma db seed