TODO: Harden anchor_id column to NOT NULL
TODO: Harden anchor_id column to NOT NULL
Problem
After PR #120, all write paths (parser + create_block API) guarantee non-null anchor_ids. But the DB column
blocks.anchor_id in models.py remains nullable=True. The invariant is enforced only at the application layer, not the schema level.Fix
Alembic migration to
ALTER COLUMN anchor_id SET NOT NULL. Must run after PR #120's migration has backfilled all existing NULLs. Update models.py to nullable=False.Prerequisites
PR #120 must be merged and its migration run first. Verify zero NULL anchor_ids exist before adding the constraint.
Related
todo-block-anchor-ids— parent TODOphase-postgres-epilogue-cleanup— Epilogue item 9b