At some point it happens to everyone. You run alembic revision --autogenerate , look at the output — and there it is: a DROP TABLE for a table that doesn't exist in production. Or the opposite: the migration history looks clean, but the production table greets you with three extra columns nobody can account for.
Because the application keeps running, the gap goes unnoticed for weeks. Then one day someone asks: "What's the actual difference between our models and the database?" Everyone looks at each other.
The tool I wrote to answer that question is SmartMigrate — a library that compares a live database against SQLAlchemy models, flags every difference by risk level, and generates runnable SQL.
The Core Idea: Two Snapshots, One Diff
At the center of the library is SchemaSnapshot — a full picture of a database schema at a given moment: tables, columns, types, indexes, foreign keys, nullable/unique/default metadata.…