The functionality of web apps change all the time, and with new functionality, we need to change the structure of our database. Whether it's adding or dropping new columns, or creation of new tables, our models will change throughout the life cycle of our app. However, problems quickly arise when the database changes often. When moving our changes from development to production, how can you be sure that you carried over every change without manually comparing each model and its corresponding table? Let's say that you wish to go back in your Git history to see if some earlier version of your app had the same bug that you are now encountering in production. How will you change your database back to the correct schema without a lot of extra work?
As programmers, we hate extra work. Thankfully, there is a tool called Alembic, which automatically creates and tracks database migrations from the changes in our SQLAlchemy models. Database migrations are records of...