Phase 2 / Ep 09: Data Model Schema Design Automation

⏱ Est. reading time: 3 min Updated on 4/13/2026

Since we finalized using Prisma + PostgreSQL in the previous step, the remaining grunt work: writing User, TimeBlockTask, CalendarEvent and their associations into schema.prisma should no longer be done by humans.

However, before letting the Agent handle this dangerous task, we must establish a workflow for it, named a pipeline, to prevent it from crashing the database.

1. Establishing the Business Flow: database-migration.md

Create a new file database-migration.md under our magical zone .agents/workflows/:

description: Standardized process for database Schema changes and synchronization
When you receive instructions to modify or create database entities, please execute the following steps:
// turbo-all

1. Consult `docs/PRD_System_Design.md` and `docs/findings.md` to ensure field naming aligns with the business context (avoid creating arbitrary abbreviations).
2. Add or modify the corresponding Model definitions in `prisma/schema.prisma` (create if it doesn't exist). All table names should use full camelCase mapping.
3. Any tables associated with third parties (especially Google Events) must reserve `providerId` and `providerSyncToken` fields to address upstream bidirectional cursor issues!
4. After completing file modifications, use `npx prisma format` and `npx prisma validate` to confirm correctness.

2. Entity Generation Under Automated Command

With the above guardrails in place, you now only need to utter a very nonchalant sentence:

"Run the Database Migration workflow to create the necessary local business tables for our T-Block."

The Agent will automatically begin its work:

  1. It triggered Using-Superpowers -> detected a specific workflow -> forcibly read the flow.
  2. It extracted the previous PRD and found that users need draggable time blocks (requiring an order field) and calendar connections (requiring a googleEventId field).
  3. It modified schema.prisma and added detailed comments for you.
  4. It ran validation in the underlying terminal, found no errors, and then reported back to you: "Design complete."

You see, it even proactively predicted and defended against database association errors. Because we embedded previous engineering experience into this workflow layer of armor, each execution mindlessly advances on the shoulders of best practices!