Docs / Guides / Migrate · seed · serve

Feature 06 · Study guide

Migrate · seed · serve

The everyday developer loop: apply schema, load sample data, run the API.

What you will learn
  • The migrate → seed → serve loop
  • What each command changes on disk / DB
  • How to combine with watch + reload

1. Setup

Project must already exist (tpy new + tpy build).

$ tpy migrate
$ tpy seed
$ tpy serve

2. What each step does

  • migrate — create DB if needed; apply pending migrations.
  • seed — run Python seeders in database/seeds/ (demo users, roles, sample rows).
  • serve — start uvicorn on app.main:app (reload on by default).

3. Recommended local DX

# terminal 1
$ tpy serve --reload

# terminal 2
$ tpy watch

Watch rebuilds layers when schema.tpy changes; serve reloads Python. After structural DB changes, still run tpy migrate.

4. Common mistakes

  • Seeding before migrate (tables missing).
  • Expecting seed to be idempotent without writing seeds that way.