Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Celaya55/app-cr/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Prisma Migrate is a declarative migration system that helps you keep your database schema in sync with your Prisma schema. It generates SQL migration files and applies them to your database.Initial Migration
The initial migration (20260218000116_init) creates the foundational database structure for App CR.
Migration Contents
What Gets Created
User Table
- Primary key
idwith auto-increment (SERIAL) - Unique email field with index
- Password field for authentication
Task Table
- Primary key
idwith auto-increment (SERIAL) - Required
titlefield - Optional
descriptionfield - Boolean
completedfield (defaults to false) - Foreign key
userIdlinking to User table
Running Migrations
Development Workflow
Apply Existing Migrations
Run all pending migrations against your database:
Use
migrate deploy in production environments. It applies migrations without prompting.Development Migration
For development with schema changes:This command:
- Creates new migration files for schema changes
- Applies migrations to the database
- Generates Prisma Client
- Prompts for migration name
Common Migration Commands
Creating New Migrations
When you modify the Prisma schema, create a new migration:Create Migration
Generate migration from schema changes:This creates:
migrations/20260306XXXXXX_add_task_priority/migration.sql- Updates Prisma Client types
Migration Files
Directory Structure
Migration Lock File
Production Migrations
Deployment Process
Deploy to Production
Apply migrations in production:
migrate deploy does not prompt or generate new migrations. It only applies existing ones.CI/CD Integration
Troubleshooting
Reset Development Database
If your development database is in an inconsistent state:Resolve Failed Migration
If a migration fails partway through:Schema Drift Detection
Check if database schema differs from migration history:Best Practices
Always review generated SQL
Always review generated SQL
Before applying migrations, review the SQL to ensure it matches your intentions:
Use descriptive migration names
Use descriptive migration names
Good:
npx prisma migrate dev --name add_task_priorityBad: npx prisma migrate dev --name updateNever edit migration files
Never edit migration files
Once a migration is committed and shared, never modify it. Create a new migration instead.
Test migrations in development
Test migrations in development
Always run and test migrations locally before deploying to production.
Backup before major migrations
Backup before major migrations
Create database backups before applying migrations in production:
Next Steps
Database Schema
View complete schema documentation
Database Setup
Configure database connection