27 lines
794 B
Python
27 lines
794 B
Python
# backend/alembic/env.py
|
|
|
|
import sys
|
|
from os.path import dirname, abspath
|
|
from logging.config import fileConfig
|
|
|
|
from sqlalchemy import engine_from_config
|
|
from sqlalchemy import pool
|
|
from alembic import context
|
|
|
|
# 1. Add your backend folder to the Python path so it can find 'app'
|
|
sys.path.insert(0, dirname(dirname(abspath(__file__))))
|
|
|
|
# 2. Import your Base, Models, and dynamic Database URL
|
|
from app.database import Base, SQLALCHEMY_DATABASE_URL
|
|
import app.models
|
|
|
|
config = context.config
|
|
|
|
if config.config_file_name is not None:
|
|
fileConfig(config.config_file_name)
|
|
|
|
# 3. OVERRIDE Alembic's config with your app's actual database URL!
|
|
config.set_main_option("sqlalchemy.url", SQLALCHEMY_DATABASE_URL)
|
|
|
|
# 4. Tell Alembic to look at your models for changes
|
|
target_metadata = Base.metadata |