scripts
This directory is for DATA MIGRATIONS ONLY.
Data migrations are not the same as schema migrations.
- Schema migrations (handled by Prisma Migrate) change the database structure — adding/removing columns, altering data types, creating new tables, etc.
- Data migrations modify the contents of the database to align with business logic changes, clean up old data, or backfill new fields without altering the schema.
Examples of data migrations:
- Populating a new column with default or computed values.
- Normalizing inconsistent text formats (e.g., fixing casing, trimming whitespace).
- Converting old enum/string values to new ones.
- Moving data between tables after a structural change has already been applied.
Guidelines:
- Idempotent when possible — running the script twice should not break data integrity.
- Version-controlled — keep a clear history of changes.
- Document assumptions — include comments explaining why the migration is needed and what it affects.
- Run after schema changes — if both schema and data changes are required, update the schema first.
⚠️ Always back up your database before running data migrations in production.