Anyone who has worked on an old code-base is familiar with this problem: the number of migrations in your versions folder gets out of hand. The database your application uses today looks nothing like the database it started with. Or, perhaps more commonly, migrations get introduced that may work for the immediate update, but somehow they break the ability to revert/replay the migrations from start to finish. In both cases, it can be nice to squash the migrations to mimic getting a fresh start.
I've been trying to find a complete example of how to squash migrations for a Flask application using SQLalchemy and Alembic. The closest thing I've found is https://alembic.sqlalchemy.org/en/latest/cookbook.html:
# inside of a "create the database" script, first create
# tables:
my_metadata.create_all(engine)
# then, load the Alembic configuration and generate the
# version table, "stamping" it with the most recent rev:
from alembic.config import Config
from alembic import command
alembic_cfg = Config("/path/to/yourapp/alembic.ini")
command.stamp(alembic_cfg, "head")
However, this terse explanation does not explain the source of the my_metadata, and I'm unclear what the alembic.ini should contain in order to complete this task. Does anyone know of a complete example of this task?