INNER CODE UNIT · Python
_initialize_database_for_startup
skygazer42/MimirQ · app/main.py:269
def _initialize_database_for_startup() -> None:
runtime_migrations_enabled = bool(getattr(settings, "DB_RUNTIME_MIGRATIONS_ENABLED", True))
create_all_enabled = bool(getattr(settings, "DB_CREATE_ALL_ON_STARTUP", True))
if runtime_migrations_enabled:
apply_runtime_migrations(engine)
if not create_all_enabled:
logger.info("DB auto-create disabled; expecting schema to be managed externally (e.g. Alembic)")
return
logger.info("Creating database tables (create_all)...")
Base.metadata.create_all(bind=engine)
if runtime_migrations_enabled:
apply_runtime_migrations(engine)
logger.info("Database initialized")