Skip to content

First Migration Cycle

Once your first model works, the next milestone is a repeatable migration workflow.

This page shows the default path used in most Edgy projects.

Prerequisite

Make sure Edgy can resolve your app instance.

Use one of:

  • --app path.to.module
  • EDGY_DEFAULT_APP=path.to.module
  • preloads in custom settings

See Application Discovery for details.

Standard Cycle

graph LR
    A["edgy init"] --> B["edgy makemigrations -m '<message>'"]
    B --> C["Review generated revision"]
    C --> D["edgy migrate"]
    D --> E["edgy current / edgy check"]

Step-by-Step

1. Initialize migration repository

$ edgy init

2. Generate migrations from model changes

$ edgy makemigrations -m "Initial schema"

3. Apply migrations

$ edgy migrate

4. Validate migration state

$ edgy current
$ edgy check

Why This Order Matters

  • init creates the migration environment once.
  • makemigrations captures model deltas explicitly.
  • migrate applies those deltas to the target database.
  • current and check prevent drift between code and schema.

Troubleshooting

If auto-discovery fails, start commands with:

$ edgy --app myproject.main migrate

If multiple heads appear:

$ edgy heads
$ edgy merge -m "Merge heads" <rev_a> <rev_b>

See Also