This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import logging
|
||||
import os
|
||||
from alembic.config import Config
|
||||
"""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__)
|
||||
@@ -20,13 +21,13 @@ def run_migrations(app):
|
||||
|
||||
# Set the SQLAlchemy URL
|
||||
alembic_cfg.set_main_option("sqlalchemy.url", database_url)
|
||||
logging.debug(f"Database URL set to: {database_url}")
|
||||
app.logger.debug(f"Database URL set to: {database_url}")
|
||||
|
||||
# Run the migration
|
||||
command.upgrade(alembic_cfg, "head")
|
||||
|
||||
logging.info("Database migration completed successfully")
|
||||
app.logger.info("Database migration completed successfully")
|
||||
return True
|
||||
except Exception as e:
|
||||
logging.error(f"Migration failed: {str(e)}")
|
||||
app.logger.error(f"Migration failed: {str(e)}")
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user