- Add Alembic configuration (alembic.ini, env.py) for database migrations - Remove legacy wheel.db and unnecessary __pycache__ files - Delete models.py to separate SQLAlchemy and Pydantic concerns - Restructure main.py to use modular API routers (user/admin) - Introduce config backend for centralized settings management
40 lines
977 B
Plaintext
40 lines
977 B
Plaintext
import sys
|
|
from os.path import abspath, dirname
|
|
import logging.config
|
|
from alembic import context
|
|
|
|
sys.path.insert(0, dirname(dirname(abspath(__file__))))
|
|
|
|
from config import DATABASE_URL, LOGGING_CONFIG
|
|
from database import Base, engine
|
|
import models
|
|
|
|
#log-settings
|
|
|
|
logging.config.dictConfig(LOGGING_CONFIG)
|
|
|
|
target_metadata = Base.metadata
|
|
|
|
def run_migrations_offline():
|
|
context.configure(
|
|
url=DATABASE_URL,
|
|
target_metadata=target_metadata,
|
|
literal_binds=True,
|
|
dialect_opts={"paramstyle": "named"},
|
|
)
|
|
with context.begin_transaction():
|
|
context.run_migrations()
|
|
|
|
def run_migrations_online():
|
|
with engine.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() |