add habit goal-period difficulty and habit formation research notes

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>
This commit is contained in:
2026-07-19 10:12:17 +09:00
co-authored by Claude Sonnet 5
parent 55918d56d1
commit d212451fe0
15 changed files with 355 additions and 9 deletions
@@ -0,0 +1,31 @@
"""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")