Completed and abandoned habits were both lumped under a single terminal state, making it impossible to tell "finished successfully" apart from "gave up" when reviewing habit history.
29 lines
946 B
Python
29 lines
946 B
Python
"""add abandoned status to habit
|
|
|
|
Revision ID: 0006_add_habit_abandoned
|
|
Revises: 0005_add_summary_notif_log
|
|
Create Date: 2026-07-17
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "0006_add_habit_abandoned"
|
|
down_revision: Union[str, None] = "0005_add_summary_notif_log"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.add_column("habit", sa.Column("abandoned_at", sa.DateTime(), nullable=True))
|
|
op.drop_constraint("ck_habit_status", "habit", type_="check")
|
|
op.create_check_constraint("ck_habit_status", "habit", "status in ('active','completed','abandoned')")
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_constraint("ck_habit_status", "habit", type_="check")
|
|
op.create_check_constraint("ck_habit_status", "habit", "status in ('active','completed')")
|
|
op.drop_column("habit", "abandoned_at")
|