Перейти к содержимому

FastAPI Alembic Migration | Add New Column with Autogenerate, Upgrade & Downgrade | Hindi

Python AI Journey

0:00 / 0:00

FastAPI Alembic Migration | Add New Column with Autogenerate, Upgrade & Downgrade | Hindi

79 просмотров · 1 мес. назад
Python AI Journey
67 подписчиков
79 просмотров · 1 мес. назад
Learn how to create and apply a real database migration in FastAPI using Alembic without losing existing data. In Part 1, we configured Alembic with an existing FastAPI database and created a baseline migration. In this Part 2 tutorial, we will add a new `phone` column to the existing `students` table, generate the migration automatically and apply it to the database. 📌 Topics Covered: ✅ Adding a new column to the SQLAlchemy model ✅ Creating an Alembic migration with `--autogenerate` ✅ Understanding the generated migration file ✅ Reviewing migration changes before applying them ✅ Understanding `upgrade()` and `downgrade()` functions ✅ Removing unwanted changes from the migration file ✅ Applying migration using `alembic upgrade head` ✅ Verifying the new column in the existing database ✅ Checking the current migration version ✅ Updating the database schema without losing existing data 📌 Commands Used: alembic revision --autogenerate -m "add phone column in students" alembic upgrade head alembic current 📌 Migration Flow: Update SQLAlchemy Model → Generate Migration → Review Migration File → Apply Migration → Verify Database This tutorial is helpful for Python developers, FastAPI beginners and backend developers who want to manage database schema changes safely using Alembic. ▶️ Watch the Complete FastAPI Playlist:    • FastAPI Complete Course in Hindi | Beginne...   💻 GitHub Code: https://github.com/vipin-chauhan-ai/f... 🔔 Subscribe to the Channel:    / @vipin-ai-v3u   If you found this video helpful, please Like, Share and Subscribe for more practical FastAPI tutorials in Hindi. #FastAPI #Alembic #DatabaseMigration #SQLAlchemy #Python