"""add note.description and note.consolidated_at Revision ID: 0044 Revises: 0043 Create Date: 2026-05-13 Adds two columns to the ``notes`` table to support the task-as-durable-record design (spec 2026-05-13): - ``description``: user-stated goal / initial context. Meaningful when ``is_task=true``; left NULL on knowledge notes. - ``consolidated_at``: timestamp of the most recent auto-summary pass. NULL until the first consolidation runs. Backfill: for existing tasks we copy ``body`` into ``description`` so the user's original goal text is preserved when ``body`` is later overwritten by the auto-summary pipeline. The brief duplication window between ``body`` and ``description`` is harmless and resolves on the first consolidation pass. """ from alembic import op import sqlalchemy as sa revision = "0044" down_revision = "0043" branch_labels = None depends_on = None def upgrade() -> None: op.add_column("notes", sa.Column("description", sa.Text(), nullable=True)) op.add_column( "notes", sa.Column("consolidated_at", sa.DateTime(timezone=True), nullable=True), ) # is_task is a Python property (status IS NOT NULL); there's no DB column # of that name. Backfill description from body for everything that # qualifies as a task at the model layer. op.execute( "UPDATE notes SET description = body " "WHERE status IS NOT NULL AND body IS NOT NULL" ) def downgrade() -> None: op.drop_column("notes", "consolidated_at") op.drop_column("notes", "description")