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 State: Single Init Migration
Section titled “Current State: Single Init Migration”The migration history was cleaned up for a fresh start. There is a single init migration that creates the complete schema from scratch. There is no portfolio table — the schema never had one. The PortfolioSnapshot table is standalone (no 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 script at backend/prisma/seed.ts populates:
- 13 asset types (Checking Account, Savings, Stocks, Crypto, Real Estate, Loan, etc.)
- 20+ categories organized hierarchically (Banking, Investments, Real Estate, etc.)
- 13 tags (high-yield, tax-advantaged, retirement, etc.)
- 6 demo assets — checking account, savings account, apartment, home loan, and two vehicles
- 4 portfolio snapshots — monthly snapshots for January–April 2025
Run with: npx prisma db seed