Ground the 21-day habit myth in actual research (Lally et al. 2010) and let users pick a target period (21/66/254 days or unlimited) matching that study's easy/median/hard automaticity timelines when creating a habit, with progress shown on the habits list. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
32 lines
873 B
Python
32 lines
873 B
Python
"""add difficulty (target period) to habit
|
|
|
|
Revision ID: 0007_add_habit_difficulty
|
|
Revises: 0006_add_habit_abandoned
|
|
Create Date: 2026-07-17
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "0007_add_habit_difficulty"
|
|
down_revision: Union[str, None] = "0006_add_habit_abandoned"
|
|
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("difficulty", sa.String(length=20), nullable=False, server_default="medium"),
|
|
)
|
|
op.create_check_constraint(
|
|
"ck_habit_difficulty", "habit", "difficulty in ('easy','medium','hard','unlimited')"
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_constraint("ck_habit_difficulty", "habit", type_="check")
|
|
op.drop_column("habit", "difficulty")
|