Skip to content

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:

  • -y, --auto-approve — skip the confirmation prompt and apply immediately. Required for non-interactive runs (CI, ECS tasks).
  • -p, --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 policy flags, so those inputs are ignored. A live database to write to is still required, and you’re still prompted for confirmation unless --auto-approve is given.
  • --no-lock — skip taking the state-store lock for this run. Use it only when you’ve coordinated access by other means (for example you already hold the lock via nschema lock acquire).

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 SCRIPT … ON PRE|POST DEPLOYMENT statements) run before and after the migration respectively.