lock acquire
Manually take the state lock. Unlike the automatic lock a write operation takes and releases, this lock outlives the command.
It is left held for out-of-band coordination, for example to claim the state before a migration window so nothing else
can write while you prepare. Release it with lock release when you’re done.
nschema lock acquirenschema lock acquire --reason "release 4.0 migration window"nschema lock acquire --ttl 2hIt prints the new lock’s id and the exact command to release it.
Scripting
Section titled “Scripting”Pass --json, to print details of the acquired lock in JSON format.
LOCK_ID=$(nschema lock acquire --json | jq -r .lockId)# ... run your out-of-band checks ...nschema lock release "$LOCK_ID" --auto-approve{ "locked": true, "lockId": "ba5edd4334d74f1a89d6f143f506fe7f", "operation": "manual", "who": "ci@runner", "since": "2026-06-27T20:30:59+00:00" }Options
Section titled “Options”--reason <text>— annotate the lock with a human-readable reason, surfaced bylock statusso others know why the state is held.--ttl <duration>— record an optional expiry on the lock (for example90s,30m,2h,1d).lock statussurfaces it, but it is never auto-enforced: the lock stays held until you release it.--json— print the held lock as a structured object on stdout (instead of formatted text), so a script can read thelockIdto release it later.