Building Data-Driven Web Apps with Flask and SQLAlchemy Transcripts
Chapter: Course conclusion
Lecture: Database migrations
0:00 ORMs are great, SQLAlchemy is great
0:02 except for once you're in production
0:04 if the database doesn't exactly match
0:07 what your SQLAlchemy classes think they should be
0:11 remember, it will crash.
0:12 Operational error, or some column doesn't exist
0:14 something like that.
0:15 So how do we solve that?
0:16 Manually syncing the database for every change we did?
0:19 No. We set up Alembic.
0:21 And we told Alembic to automatically look at our classes
0:25 and remap our database schema
0:27 with migrations to make that happen.
0:29 So there's a couple manual steps you got to do here
0:31 but once you get it set up
0:32 it's pretty easy, you just run a command
0:35 apply that change by saying alembic upgrade head.