Skip to content

nschema apply

Compute the plan and apply it to the target database. Prompts for confirmation before making changes unless --auto-approve is given.

Terminal window
nschema apply
nschema apply --plan-file tonight.nplan # apply exactly what plan --out saved

apply accepts every plan option, plus:

  • --auto-approve — skip the confirmation prompt and apply immediately. Required for non-interactive runs (CI, ECS tasks).
  • --plan-file <path> — replay a plan saved by plan --out, executing exactly that plan instead of computing a fresh one (Terraform’s apply <planfile>). The saved plan already fixes its scope, desired schema, and destructive-action policy, so those inputs are ignored — and the *.sql files need not be present. A live database to write to is still required, and you’re still prompted for confirmation unless --auto-approve is given.

If a state store is configured, the resulting schema is captured to it after a successful apply, so later offline plans can run against that snapshot.

Deployment scripts (inline PRE/POST DEPLOYMENT blocks) run on every apply, before and after the migration respectively.