alembic fix

This commit is contained in:
2026-06-01 16:34:07 +03:00
parent e12a9ddfce
commit 4c5da7e4d9
15 changed files with 346 additions and 90 deletions

View File

@@ -760,15 +760,17 @@ def _ensure_dictionary_entries_columns(bind_engine):
# #region init_db [C:3] [TYPE Function]
# @BRIEF Creates any missing tables via create_all().
# @BRIEF Creates any missing tables via create_all() — safety net for development.
# @PRE engine, tasks_engine and auth_engine are initialized.
# Alembic migrations (run_alembic_migrations) have already been applied.
# In Docker: Alembic migrations already applied via entrypoint.sh.
# @POST All tables from SQLAlchemy models exist in all databases.
# @SIDE_EFFECT Creates physical database tables if they don't exist.
# @RATIONALE Schema migrations are handled by Alembic (run_alembic_migrations runs
# before init_db in startup_event). create_all() only creates NEW tables
# that don't exist yet — it does NOT alter existing ones. All column
# additions must go through Alembic migrations.
# @RATIONALE create_all() is idempotent — it only creates tables that don't exist,
# never alters existing ones. In Docker, Alembic runs first in entrypoint.sh
# (wait_for_db → alembic upgrade head), so init_db() is a no-op for production.
# For local development (run.sh without Docker), this provides a safety net.
# @REJECTED Removing init_db() entirely was rejected — local development without
# Docker would require manual Alembic setup, increasing friction for developers.
# @REJECTED _ensure_*() inline additive migrations removed — they were duplicating
# Alembic logic, were not versioned, and created hidden schema drift.
# All schema changes must now go through Alembic.