When a schema proposal is approved, automatically generate and apply the database migration.
For metadata-level changes (JSON fields), generate a backfill script. For column-level
changes, generate ALTER TABLE migrations compatible with the migration runner.
generate_migration(proposal_id) function that produces migration SQLjsonb_set(...) backfill SQL generated for metadata changesALTER TABLE plans generated with defaults and optional indexesARTIFACT_TYPES constant with rollback-safe restoration on failuremigration_history tablesen-sg-02-PROP — Approved proposals trigger thissen-sg-03-VALD — Post-migration validation confirms integrityorigin/main and live PostgreSQL schema.scidex/senate/schema_governance.py finalized approved schema proposals with a log line only and did not define the migration helpers described in docs/schema_governance_guide.md.migration_history only tracked (version, name, applied_at, execution_time_ms, status) and was missing proposal/rollback/schema-version metadata required by this task.jsonb_set and temporary-table copy validation instead of the original SQLite-style json_set / in-memory-copy wording in the spec.tests/test_schema_migration.py and reviewed the generated SQL paths for metadata, column, and add_type proposals.artifact_registry.py if an add_type migration aborts mid-transaction.scidex/senate/schema_migration.py: copy-test failures now roll back the open transaction, and add_type restores artifact_registry.py if the DB migration aborts mid-flight.8 passed).senate-prop-b54f3d4b9d61, which generated an ALTER TABLE artifacts ADD COLUMN IF NOT EXISTS effect_size DOUBLE PRECISION; plan for the approved schema shape.python3 -m py_compile for scidex/senate/schema_migration.py, scidex/senate/schema_governance.py, and tests/test_schema_migration.py.pytest -q tests/test_schema_migration.py and confirmed 8 passed in 0.14s.senate-prop-b54f3d4b9d61; preview SQL and temporary-table validation both succeeded against current data.pytest -q tests/test_schema_migration.py → 8 passed in 0.64s. All acceptance criteria confirmed complete..orchestra-slot.json and .orchestra/audit/ (orchestration artifacts, not task code).judge_chain_error (judge LLM quota exhaustion), not code failures.python3 -m py_compile clean on all 3 source files; pytest -q tests/test_schema_migration.py → 8 passed in 0.13s.origin/main, exactly on the intended diff (4 files, 1075 net insertions).