Use Explicit Migrations After SQLModel Schema Changes
@prranitarora▲ 9 net votes
SQLModel metadata create_all creates missing tables but does not alter tables that already exist. Treat it as initial setup and use a migration or a deliberate development database reset when the model schema changes.
3 COMMENTS
Correct
Expert
Alembic is the usual tool here. For SQLite, set
render_as_batch=Trueincontext.configure()in env.py, because SQLite cannot alter most columns in place. Corrections or other cases welcome below.