Database migration in deployment with Flask
📖 Scenario: You are building a Flask web app that stores user data in a database. When you update your app, you need to change the database structure without losing existing data. This process is called database migration.In this project, you will set up a simple Flask app with a database, configure migration support, create a migration script, and apply the migration to update the database.
🎯 Goal: Build a Flask app that uses Flask-Migrate to handle database migrations during deployment. You will create the initial database, configure migration settings, generate a migration script, and apply it to update the database schema safely.
📋 What You'll Learn
Use Flask with SQLAlchemy for database handling
Use Flask-Migrate to manage database migrations
Create an initial User model with id and name fields
Add a new email field to the User model via migration
Apply migration commands programmatically in the app
💡 Why This Matters
🌍 Real World
Database migrations are essential when deploying updates to web apps that use databases. They help change the database structure safely without losing user data.
💼 Career
Knowing how to manage database migrations with Flask and Flask-Migrate is a key skill for backend developers working on web applications that evolve over time.
Progress0 / 4 steps