sudacode b7aa64935f
All checks were successful
Build Docker Image / build (push) Successful in 13m47s
fix logging
2025-02-15 00:35:41 -08:00

34 lines
945 B
Python

"""Migrations module"""
from alembic import command
from alembic.config import Config
from flask import Blueprint
from app.config import Config as AppConfig
migrations_bp = Blueprint("migrations", __name__)
def run_migrations(app):
"""Run database migrations"""
try:
# Create Alembic configuration object
alembic_cfg = Config("alembic.ini")
# Get the database URL from your app's config
database_url = AppConfig.SQLALCHEMY_DATABASE_URI
print(database_url)
# Set the SQLAlchemy URL
alembic_cfg.set_main_option("sqlalchemy.url", database_url)
app.logger.debug(f"Database URL set to: {database_url}")
# Run the migration
command.upgrade(alembic_cfg, "head")
app.logger.info("Database migration completed successfully")
return True
except Exception as e:
app.logger.error(f"Migration failed: {str(e)}")
return False