refactor: integrate Alembic, restructure project, and clean up
- 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
This commit is contained in:
40
backend/.config
Normal file
40
backend/.config
Normal file
@@ -0,0 +1,40 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user