Skip to main content

db apply

Apply the planned schema changes to the local cloned database.

Usage

postkit db apply [-f]

Options

OptionDescription
-fSkip confirmation prompts
-v, --verboseEnable verbose output
--dry-runShow what would be done without making changes
--jsonOutput as JSON

What It Does

  1. Validates per-schema fingerprints (ensures schema files haven't changed since plan)
  2. Displays the planned changes
  3. Tests local database connection
  4. Applies infrastructure SQL from db/infra/
  5. For each schema with changes: wraps plan SQL with SET search_path TO "<name>" and combines into one migration file (staged in .postkit/db/session/)
  6. Runs dbmate migrate on the local database
  7. Applies seed data from db/schema/<name>/seeds/ for each schema in config order

Resume support: If seeds fail, re-running postkit db apply resumes from where it left off.

Requirements

  • An active session must exist
  • A plan must exist (run db plan first)
  • plan - Generate schema diff
  • commit - Commit for deployment