<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import os
import sys
from logging.config import fileConfig

from sqlalchemy import engine_from_config, pool
from alembic import context

# Make sure "app/" is on Python path
sys.path.append(os.getcwd())

# Import settings and Base metadata
from backend.app.core.database import settings      # reads .env
from backend.app.core.database import Base

# Import all models -&gt; tables are registered
import backend.app.models.user
import backend.app.models.mindmap
import backend.app.models.node
import backend.app.models.vote

# Provides access to values within alembic.ini
config = context.config

# Override the URL in alembic.ini with the one from .env
config.set_main_option("sqlalchemy.url", str(settings.DIRECT_URL))

# Interpret the config file for Python logging
if config.config_file_name is not None:
    fileConfig(config.config_file_name)

# Link Alembic to Metadata
target_metadata = Base.metadata

def run_migrations_offline() -&gt; None:
    """Run migrations without an engine"""
    url = config.get_main_option("sqlalchemy.url")
    context.configure(
        url=url,
        target_metadata=target_metadata,
        literal_binds=True,
        dialect_opts={"paramstyle": "named"},
    )
    with context.begin_transaction():
        context.run_migrations()


def run_migrations_online() -&gt; None:
    """Run migrations with an engine"""
    connectable = engine_from_config(
        config.get_section(config.config_ini_section, {}),
        prefix="sqlalchemy.",
        poolclass=pool.NullPool,
    )
    with connectable.connect() as connection:
        context.configure(
            connection=connection,
            target_metadata=target_metadata,
        )
        with context.begin_transaction():
            context.run_migrations()


if context.is_offline_mode():
    run_migrations_offline()
else:
    run_migrations_online()
</pre></body></html>