tcb db pg migration repair
Repair the remote migration history. Use it to backfill records, mark a rollback, or align checksums.
⚠️ This command does not execute SQL; marking a migration
reverteddoes not roll back the database.
Usage
tcb db pg migration repair <version> --status <applied|reverted> --reason <reason> -e <envId>
Parameters
| Parameter | Required | Description | Default |
|---|---|---|---|
<version> | Yes | 14-digit migration version | — |
--status <status> | Yes | Target status: applied or reverted | — |
--reason <reason> | Yes | Repair reason, kept for auditing | — |
--dry-run | No | Preview the repair plan without applying it | false |
-e, --env-id <envId> | Yes | Environment ID | — |
--json | No | Output JSON | — |
Examples
# Mark a local migration as applied, for example after running the SQL directly in the database
tcb db pg migration repair 20260724153000 --status applied --reason "manual_fix" -e <envId>
# Mark a remote history record as reverted
tcb db pg migration repair 20260724153000 --status reverted --reason "rollback_record" -e <envId>
# Preview the repair plan first
tcb db pg migration repair 20260724153000 --status applied --reason "checksum_align" -e <envId> --dry-run
Notes
Nameis inferred automatically, no need to pass it--status appliedlooks up the version file in the local directory and reads its SQL; a missing file raises an error--status revertedreadsNamefrom the remote history and does not use local files- When
checksum_mismatchappears, sync the remote content first withmigration fetch <version> --force