Feature 03 · Study guide
Understand migrate: create missing SQL databases, apply ordered migrations, roll back safely.
You need a project with generated migrations and a valid .env (from tpy build or tpy db configure).
$ tpy migrate $ tpy migrate status $ tpy migrate rollback
database/migrations/ in numeric order (001_, 002_, …).database/migrations/ 001_user_migration.py 002_post_migration.py
Each file provides up (apply) and down (undo). Model order in schema.tpy becomes migration order — define referenced models first.
tpy crud — regenerate migration + layers.tpy migrate — apply new pending files.tpy migrate status — confirm what ran.tpy build/tpy crud (no migration files yet).