Give autogenerated migrations sequential numbers
Right now make migration msg="..." lets Alembic pick the revision id, so every new file lands with a random hash prefix like 621bb06ff5d1_...py. The first two migrations are numbered 001_ and 002_, so the folder mixes two styles and you can't tell the order of revisions by looking at the file names.
Scope
- Update the
migration target so it takes a rev argument and passes it to Alembic as --rev-id. Alembic's default file name is <rev>_<slug>.py, so a numbered rev makes the file land in order (for example 003_...py).
- Make
rev required, with a short usage hint when it is missing.
- Note the workflow in the docs: bump to the next number, zero-padded to three digits.
Example:
make migration rev=0xx msg="<migration message>"
Give autogenerated migrations sequential numbers
Right now
make migration msg="..."lets Alembic pick the revision id, so every new file lands with a random hash prefix like621bb06ff5d1_...py. The first two migrations are numbered001_and002_, so the folder mixes two styles and you can't tell the order of revisions by looking at the file names.Scope
migrationtarget so it takes arevargument and passes it to Alembic as--rev-id. Alembic's default file name is<rev>_<slug>.py, so a numbered rev makes the file land in order (for example003_...py).revrequired, with a short usage hint when it is missing.Example: