bashartc14/todo_backend
0
1"""Script to run database migrations manually."""2import os3import sys4from sqlmodel import SQLModel, create_engine5from alembic import command6from alembic.config import Config7 8# Add the backend directory to the Python path9sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))10 11# Import the task model to ensure it's registered with SQLModel metadata12try:13 from models.task import Task14except ImportError:15 from app.models.task import Task16 17def run_migrations():18 """Run database migrations."""19 # Create the alembic config20 alembic_cfg = Config("alembic.ini")21 22 print("Running database migrations...")23 command.upgrade(alembic_cfg, "head")24 print("Migrations completed successfully!")25 26if __name__ == "__main__":27 run_migrations()