with one click
migration-apply
// Apply a numbered SQL migration via psql, verify it ran, run the relevant export regen, and record provenance in the session report. Reads the migration first; never applies blindly.
// Apply a numbered SQL migration via psql, verify it ran, run the relevant export regen, and record provenance in the session report. Reads the migration first; never applies blindly.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | migration-apply |
| description | Apply a numbered SQL migration via psql, verify it ran, run the relevant export regen, and record provenance in the session report. Reads the migration first; never applies blindly. |
| allowed-tools | Bash, Read |
Applies a numbered migration file from 02 ONTARA/db/migrations/NNN_*.sql to the local ontara PostgreSQL database. The migration is read first, presented for confirmation, applied via psql -f, verified, and any affected exporter regen is run.
/migration-apply <path-to-migration>
Examples:
/migration-apply 02 ONTARA/db/migrations/041_add_strata_landing_status.sql/migration-apply db/migrations/042_work_item_acceptance.sqlpsql -d ontara -c "SELECT 1" 2>&1 | head -3
ls -l "<migration-path>"
curl http://localhost:7300/healthz
Read the migration file in full. Do not skim. Identify:
Confirm with Ella before applying. Show:
Apply the migration:
cd "/Users/ellagreen/Obsidian/GenderSense/02 ONTARA"
psql -d ontara -f "<migration-path>"
psql -f runs in a single transaction by default in modern Postgres, so a failure mid-file rolls back. If the migration uses explicit BEGIN/COMMIT, that takes precedence.
Verify the migration ran. Depending on the migration:
psql -d ontara -c "\d+ <table-name>"
psql -d ontara -c "SELECT count(*) FROM <table>"
psql -d ontara -c "SELECT * FROM <table> LIMIT 3"
\d+ (indexes appear in the bottom block) or \dn+ for constraints.Run affected exporter regen if the migration changed marker-bound table content. The regen replays the (possibly new) row shape into vault markdown:
python3 -c "import sys; sys.path.insert(0, 'db'); from exports.<module> import regenerate_<topic>_section; regenerate_<topic>_section()"
Skip this step if the migration only added schema and no rows yet exist with the new shape.
Restart the resolver if the migration added a new content type or changed a spec's expected schema โ the resolver loads specs at import time:
launchctl kickstart -k gui/501/dev.ontara.resolver
sleep 2
curl http://localhost:7300/healthz
Record provenance. In the session report, note:
psql -f <file>. Multi-statement files in interactive mode are subject to autocommit edge cases.block, block_edge, document, document_block, revision) without confirming with Ella โ these tables carry reconciliation logic in the resolver and changes need coordinated code updates.psql -d ontara -f <file> returns non-zero with a SQL error: the transaction rolled back. Read the error verbatim. Common causes:
psql -f failed mid-file but some statements committed (e.g. the migration didn't wrap in BEGIN), recovery requires writing a hand-crafted patch. Stop and ask Ella.02 ONTARA/db/migrations/NNN_<description>.sql in the vault.02 ONTARA/db/schema/ is a flattened view; it is regenerated separately and lags migrations.psql -f for transactional integrity and error visibility.ontara-ref-guide-db-access.md ยง9 for the migration discipline.ontara-ref-guide-using-claude-tools.md ยง2.2 โ migration authoring is a soft handoff trigger; this skill covers application, which is the after-authoring step.