Initial commit: InviteMe production redesign
This commit is contained in:
+13
-1
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user