"""add status (done/failed) to habit_log Revision ID: 0009_add_habit_log_status Revises: 0008_normalize_habit_enum_casing Create Date: 2026-07-20 "어제 놓친 습관" 배너에서 사용자가 명시적으로 실패를 확정할 수 있게 하기 위해, "로그 행이 존재하면 그 날 체크 완료"라는 기존 불변식을 유지하면서도 "완료"와 "실패"를 구분해야 한다. status 컬럼을 추가하고 기존 행은 전부 완료였으므로 기본값 'done'으로 채운다. """ from typing import Sequence, Union import sqlalchemy as sa from alembic import op revision: str = "0009_add_habit_log_status" down_revision: Union[str, None] = "0008_normalize_habit_enum_casing" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.add_column( "habit_log", sa.Column("status", sa.String(length=20), nullable=False, server_default="done"), ) op.create_check_constraint("ck_habit_log_status", "habit_log", "status in ('done','failed')") def downgrade() -> None: op.drop_constraint("ck_habit_log_status", "habit_log", type_="check") op.drop_column("habit_log", "status")