"""add coaching_preferences and coaching_checkin (Phase 3) Revision ID: 005 Revises: 004 Create Date: 2026-06-16 Phase 3: coaching preferences (auto-generated from the profile, user-overridable) and periodic coaching check-ins that quote the person's own words and ask whether their direction still feels valid. """ from typing import Sequence, Union import sqlalchemy as sa from alembic import op revision: str = "005" down_revision: Union[str, None] = "004" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.create_table( "coaching_preferences", sa.Column("id", sa.String(), primary_key=True), sa.Column( "user_id", sa.String(), sa.ForeignKey("users.id"), nullable=False, unique=True, ), sa.Column( "profile_id", sa.String(), sa.ForeignKey("discovery_profile.id"), nullable=True, ), sa.Column("coaching_frequency", sa.String(), nullable=False), sa.Column("coaching_style", sa.String(), nullable=False), sa.Column("misalignment_threshold", sa.String(), nullable=False), sa.Column("friction_tolerance", sa.String(), nullable=False), sa.Column( "prefer_questions_over_directives", sa.Boolean(), nullable=False, server_default=sa.text("1"), ), sa.Column("time_of_day_preference", sa.String(), nullable=False), sa.Column( "auto_generated", sa.Boolean(), nullable=False, server_default=sa.text("1"), ), sa.Column("created_at", sa.DateTime(), nullable=False), sa.Column("updated_at", sa.DateTime(), nullable=False), ) op.create_index( "ix_coaching_preferences_user_id", "coaching_preferences", ["user_id"], ) op.create_table( "coaching_checkin", sa.Column("id", sa.String(), primary_key=True), sa.Column( "user_id", sa.String(), sa.ForeignKey("users.id"), nullable=False, ), sa.Column( "profile_id", sa.String(), sa.ForeignKey("discovery_profile.id"), nullable=False, ), sa.Column("body", sa.Text(), nullable=False), sa.Column("created_at", sa.DateTime(), nullable=False), sa.Column("still_valid", sa.Boolean(), nullable=True), sa.Column("response_note", sa.Text(), nullable=True), sa.Column("acknowledged_at", sa.DateTime(), nullable=True), ) op.create_index( "ix_coaching_checkin_user_id", "coaching_checkin", ["user_id"] ) op.create_index( "ix_coaching_checkin_created_at", "coaching_checkin", ["created_at"] ) def downgrade() -> None: op.drop_index( "ix_coaching_checkin_created_at", table_name="coaching_checkin" ) op.drop_index( "ix_coaching_checkin_user_id", table_name="coaching_checkin" ) op.drop_table("coaching_checkin") op.drop_index( "ix_coaching_preferences_user_id", table_name="coaching_preferences" ) op.drop_table("coaching_preferences")