17 lines
530 B
Python
17 lines
530 B
Python
from sqlalchemy import create_engine, Column, Integer, String, Engine
|
|
from alembic.config import Config
|
|
from alembic import command
|
|
from dotenv import dotenv_values
|
|
|
|
# Function to perform the database migration
|
|
def migrate_db(engine: Engine, db_url):
|
|
# Configure Alembic
|
|
alembic_cfg = Config()
|
|
alembic_cfg.set_main_option("script_location", "migrations")
|
|
alembic_cfg.set_main_option("sqlalchemy.url", db_url)
|
|
|
|
# Run migrations using Alembic
|
|
command.upgrade(alembic_cfg, "head")
|
|
|
|
print('db up to date')
|