MVP ready. Fully functional (registration? moderation, profiles vew)
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
2025-08-12 21:55:56 +09:00
parent b282c44e7c
commit 9af84db429
17 changed files with 782 additions and 18 deletions

View File

@@ -1,24 +1,42 @@
from __future__ import annotations
import os
import os, sys
from logging.config import fileConfig
from sqlalchemy import engine_from_config, pool
from alembic import context
config = context.config
# Подменяем URL из переменных окружения контейнера
if os.getenv("DATABASE_URL"):
config.set_main_option("sqlalchemy.url", os.getenv("DATABASE_URL"))
fileConfig(config.config_file_name)
# Возьми URL из переменных контейнера
db_url = os.getenv("DATABASE_URL")
if db_url:
config.set_main_option("sqlalchemy.url", db_url)
# Лог-конфиг (без падения, если секций нет)
cfg_name = config.config_file_name
if cfg_name:
try:
fileConfig(cfg_name)
except Exception:
pass
# Обеспечим PYTHONPATH=/app для импорта пакета app
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if ROOT not in sys.path:
sys.path.insert(0, ROOT)
# Метаданные моделей
from app.models.base import Base # noqa: E402
from app.models.base import Base # noqa
target_metadata = Base.metadata
def run_migrations_offline():
url = config.get_main_option("sqlalchemy.url")
context.configure(url=url, target_metadata=target_metadata, literal_binds=True,
dialect_opts={"paramstyle": "named"})
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()