[FIXED] alembic how to merge all revision files to one file?

Issue

There are more than 100 files in alembic version directory. How to use alembic command to merge these file into a one file?

I am try to use this:

alembic revision --autogenerate

but doesn’t work! Anyone has good idea?

Solution

If you have all the models in models.py (or whatever you use for models), it should be possible to achieve your goal by recreating migrations in a single file. Like this:

  1. Point Alembic to a different and empty database
  2. run alembic revision --autogenerate
  3. You’ll get the mirroring revision in a single file.

Answered By – Igor

Answer Checked By – Gilberto Lyons (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published