From fba11ff4ccb08f042372e591b3f54b7019e33087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D1=81=D1=82=D0=B0=D0=BD=D1=82=D0=B8?= =?UTF-8?q?=D0=BD=20=D0=9B=D0=B5=D0=B1=D0=B5=D0=B4=D0=B8=D0=BD=D1=81=D0=BA?= =?UTF-8?q?=D0=B8=D0=B9?= Date: Wed, 29 Apr 2026 21:36:54 +0500 Subject: [PATCH] =?UTF-8?q?Alembic:=20=D0=BA=D0=BE=D0=BB=D0=BE=D0=BD=D0=BA?= =?UTF-8?q?=D0=B8=20tests.hints=5Fenabled=20=D0=B8=20tests.result=5Fmode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ревизия 0002 добавляет поля в таблицу tests (IF NOT EXISTS для PostgreSQL). Dockerfile копирует alembic.ini и каталог alembic в образ, чтобы можно было запускать alembic upgrade head в контейнере. Made-with: Cursor --- flask_app/Dockerfile | 2 + .../versions/0002_tests_hints_result_mode.py | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 flask_app/alembic/versions/0002_tests_hints_result_mode.py diff --git a/flask_app/Dockerfile b/flask_app/Dockerfile index f7ac68a..1666e9e 100644 --- a/flask_app/Dockerfile +++ b/flask_app/Dockerfile @@ -15,6 +15,8 @@ RUN pip install --no-cache-dir -r requirements.txt COPY run.py . COPY app ./app +COPY alembic.ini . +COPY alembic ./alembic EXPOSE 3108 diff --git a/flask_app/alembic/versions/0002_tests_hints_result_mode.py b/flask_app/alembic/versions/0002_tests_hints_result_mode.py new file mode 100644 index 0000000..82279bb --- /dev/null +++ b/flask_app/alembic/versions/0002_tests_hints_result_mode.py @@ -0,0 +1,38 @@ +"""Добавление hints_enabled и result_mode в tests. + +Revision ID: 0002_tests_hints_result_mode +Revises: 0001_baseline +Create Date: 2026-04-29 + +Совместимо с БД, где колонки уже есть: используется ADD COLUMN IF NOT EXISTS (PostgreSQL). +""" +from __future__ import annotations + +from typing import Sequence, Union + +from alembic import op + +revision: str = "0002_tests_hints_result_mode" +down_revision: Union[str, None] = "0001_baseline" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + op.execute( + """ + ALTER TABLE tests + ADD COLUMN IF NOT EXISTS hints_enabled BOOLEAN NOT NULL DEFAULT false; + ALTER TABLE tests + ADD COLUMN IF NOT EXISTS result_mode VARCHAR(16) NOT NULL DEFAULT 'end'; + """ + ) + + +def downgrade() -> None: + op.execute( + """ + ALTER TABLE tests DROP COLUMN IF EXISTS hints_enabled; + ALTER TABLE tests DROP COLUMN IF EXISTS result_mode; + """ + )