Initial commit: InviteMe production redesign

This commit is contained in:
InviteMe Developer
2026-09-01 10:39:12 +03:00
parent d54a17b0ad
commit 35ab540c71
2 changed files with 15 additions and 1 deletions
+13 -1
View File
@@ -52,8 +52,8 @@ def create_app(config_class=Config):
with app.app_context():
if not app.config.get("SKIP_DB_BOOTSTRAP"):
_run_migrations()
if not app.config.get("IS_PRODUCTION"):
db.create_all()
_migrate_existing_data(app)
_migrate_legacy_public_uploads(app)
_load_smtp_settings(app)
@@ -61,6 +61,18 @@ def create_app(config_class=Config):
return app
def _run_migrations():
"""Применяет миграции Alembic к текущей базе данных."""
from alembic.config import Config as AlembicConfig
from alembic import command
migrations_dir = Path(__file__).resolve().parent.parent / "migrations"
alembic_ini = migrations_dir / "alembic.ini"
alembic_cfg = AlembicConfig(str(alembic_ini))
alembic_cfg.set_main_option("script_location", str(migrations_dir))
command.upgrade(alembic_cfg, "head")
def _load_smtp_settings(app):
"""Загружает SMTP-настройки из базы в конфиг приложения."""
try: