Skip to content

lock status

Show whether the state store is currently locked. It reads the lock, if there is one, and surfaces who holds it, the operation, when it was taken, and the id you need to release it.

Terminal window
nschema lock status

When locked, it prints the lock’s details and the exact command to release it:

⚠ The state is locked.
Lock ID: 9f8e7d6c
Held by: alice@ci
Operation: apply
Since: 2026-06-25 10:00:00Z
Release it, once you're sure no operation is still running, with: nschema lock release 9f8e7d6c

If the lock records a --ttl, the expiry is surfaced here too (it is informational only: NSchema never auto-enforces it). For a broader health check (database + state store + lock together) see doctor.

  • --detailed-exitcode — return a detailed exit code: 0 when the state is not locked, 2 when it is locked (errors stay 1), so a CI job can gate on it. Without it, lock status always exits 0 and you read the state from its output.

  • --json — emit a single structured object instead of text, for scripting:

    { "locked": true, "lockId": "9f8e7d6c", "operation": "apply", "who": "alice@ci", "since": "2026-06-25T10:00:00+00:00" }

    When not locked, it is simply { "locked": false }.