Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

migration-judged-apply

БесплатноБез исполняемых скриптовНе проверен

Apply a merged migration SQL file to a product app's production database through its own /api/internal/migrations/apply endpoint — deploy gate first…

cromford-aiот cromford-ai★ 29 звёзд на GitHub

Об этом скилле

migration-judged-apply

The fleet never holds a database credential. Every schema change is applied by the app itself, from the SQL already baked into its deployed bundle, triggered by a filename over an internal-token-gated endpoint. This skill is the procedure for driving that by hand, and for judging the cases the automation deliberately parks.

Spec: docs/MIGRATION_ENDPOINT_SPEC.html. Automation that already does this: bin/migration-autopilot.sh (allowlisted files, post-deploy) and bin/apply-migrations.sh (cron */15, pending-file sweep). Check whether the autopilot already owns the file before doing anything by hand — see step 0.

Iron laws (these bind you, not just the scripts)

  1. Never apply before the deploy that carries the code serves. A file only becomes addressable once it is in the running bundle, so the schema can never land ahead of the code that reads it. Verify the serving sha contains the merge commit — do not infer it from "the PR merged a while ago" (TK-64: finance tables sat unapplied for days while deployed code threw on every load).
  2. Additive only. ADD COLUMN IF NOT EXISTS, new tables, new named constraints, new indexes, new enum values. Re-running must be a no-op.
  3. Every new table gets ALTER TABLE … ENABLE ROW LEVEL SECURITY plus REVOKE ALL … FROM anon, authenticated in the same migration. A wave that creates no table has no RLS step — say so rather than skipping silently.
  4. A classifier-FLAGGED file is never auto-applied. Flagged means a human reads the SQL first. You may apply it by hand after reading it and judging it safe, and you say in the record that you did so and why.
  5. Verify after apply, against the app's own status ledger — never the apply response. {ok:true} is a claim; the ledger listing the filename is proof.
  6. On failure: ONE actionable ALERTS.log line, then stop. Never retry-loop. Migrations inside a project are order-dependent, so a failure stops the whole sequence, not just the failing file. A refusal is deterministic per checksum — re-POSTing an unchanged file can only re-fire the alert (the 2026-08-06 pb67 alert storm is exactly this).
  7. You never touch a production database directly. No prisma db push, no psql, no Supabase SQL editor from this box. The endpoint or nothing.

Wiring (never guessed — read it, per project)

Env lives in /root/harness/env/global.env + /root/harness/env/<project>.env (chmod 600, never in git; keys documented in env-templates/project.env.example). Two separate least-privilege secrets:

  • MIGRATION_TOKEN — the status / apply endpoints.
  • <PREFIX>_INTERNAL_API_TOKEN — the /api/internal/version endpoint only.

App base URLs, as bin/migration-autopilot.sh maps them:

project base var version token var
project-1 PROJECT_1_API_BASE PROJECT_1_INTERNAL_API_TOKEN
project-2 PROJECT_2_APP_BASE PROJECT_2_INTERNAL_API_TOKEN
project-3 PROJECT_3_APP_BASE PROJECT_3_INTERNAL_API_TOKEN
project-4 PROJECT_4_API_BASE PROJECT_4_INTERNAL_API_TOKEN

A project not in that table has no wiring. Stop and say so; do not guess a base URL.

P=project-2                                   # the project
set -a; . /root/harness/env/global.env; . /root/harness/env/$P.env; set +a
BASE="$PROJECT_2_APP_BASE"                               # from the table above
MIG() { curl -sf -m 60 -H "Authorization: Bearer $MIGRATION_TOKEN" -H 'User-Agent: curl/8' "$@"; }

Procedure

0. Is this already owned by the automation?

( . /root/harness/bin/jobs-client.sh; job_ledger_get migration "$P <file>" ); echo "rc=$?"  # rc 0 = row (status printed), 2 = none, 1 = could not ask
cat /root/harness/state/migrations-refused-$P.txt                # terminal refusals
tail -30 /root/harness/logs/migrations.log
grep -i migration /root/harness/logs/ALERTS.log | tail -10

A file whose ledgers(kind=migration) row reads applied is done. A file whose row reads flagged, or that is listed in migrations-refused-*, is parked on purpose and is waiting for the judgement you are about to make. Never clear that row or that file to "make it retry" without first establishing why it failed.

1. What does the app say is pending?

MIG "$BASE/api/internal/migrations/status" | jq '{applied: [.applied[]?.filename] | length, pending: [.pending[]? | {filename, statements}]}'

status compares the deployed bundle's scripts/migrations/ against the app's MigrationApplied ledger. An empty pending list on an app you know has a new file usually means the file is not in the bundle: Vercel serverless functions do not include arbitrary repo files, so the app's next.config needs outputFileTracingIncludes for scripts/migrations/**. That failure mode is fail-safe (nothing to apply, nothing breaks) and it is a repo fix, not an apply.

project-4 answers a mu

Полный SKILL.md на GitHub

Установить migration-judged-apply в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл migration-judged-apply?

Apply a merged migration SQL file to a product app's production database through its own /api/internal/migrations/apply endpoint — deploy gate first, classifier verdict respected, verified against the app's own ledger, one ALERT and stop on failure. Use when a migration is pending, an apply was refused or flagged, or someone asks to "apply the migration" / "why is this migration stuck".

Как установить скилл migration-judged-apply?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл migration-judged-apply запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить migration-judged-apply с