Skip to content

destroy

Drop everything NSchema manages from the target database. Prompts for confirmation before making changes unless --auto-approve is given.

Terminal window
nschema destroy

Destroy only removes objects from the managed schema, meaning anything in the database outside the scope of the project will be left untouched. The live schema is captured before the teardown is planned, so it covers what the database actually holds, and the state store is refreshed again after it runs.

  • -y, --auto-approve — skip the confirmation prompt. Required for non-interactive runs.
  • --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).
  • --no-refresh — plan the teardown against the recorded state as-is, without capturing the live schema first. Managed objects created outside NSchema since the last run will be left behind.
  • --ephemeral — run against an in-memory state store discarded when the command exits. See Ephemeral state.

To tear down part of a project rather than all of it, remove the declarations and apply, or preview a partial teardown with plan --destroy --scope.

Like a declined apply, a declined destroy makes no changes and exits 1.