Alembic: колонки tests.hints_enabled и tests.result_mode
Ревизия 0002 добавляет поля в таблицу tests (IF NOT EXISTS для PostgreSQL). Dockerfile копирует alembic.ini и каталог alembic в образ, чтобы можно было запускать alembic upgrade head в контейнере. Made-with: Cursor
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
"""
|
||||
)
|
||||
Reference in New Issue
Block a user