Skip to main content

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 reverted does not roll back the database.

Usage​

tcb db pg migration repair <version> --status <applied|reverted> --reason <reason> -e <envId>

Parameters​

ParameterRequiredDescriptionDefault
<version>Yes14-digit migration version—
--status <status>YesTarget status: applied or reverted—
--reason <reason>YesRepair reason, kept for auditing—
--dry-runNoPreview the repair plan without applying itfalse
-e, --env-id <envId>YesEnvironment ID—
--jsonNoOutput 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​

  • Name is inferred automatically, no need to pass it
  • --status applied looks up the version file in the local directory and reads its SQL; a missing file raises an error
  • --status reverted reads Name from the remote history and does not use local files
  • When checksum_mismatch appears, sync the remote content first with migration fetch <version> --force