- Docs
- Self-host and operate
- Store maintenance
Store maintenance
Two commands for the person who runs the store. Both go through the same store selection as the
rest of the command line (CLI reference, “Which store a command uses”), except where noted. In a
self-hosted deployment they run as services (migrate once at start, retention hourly,
the self-hosting guide); this page is for running them by hand.
Prerequisites
Section titled “Prerequisites”- Shell access to the host, with NuraMesh installed.
- For
db migrate:NURAMESH_DATABASE_URLset, and the rights of the table owner. - A backup taken first when a migration is not additive (Back up and restore).
- Read the plan:
nuramesh db migrate --planprints what is pending and changes nothing. - Apply the migrations with
nuramesh db migrate, acknowledging the backup when it asks. - Give the service role its rights with
--grant-to, as the table owner. - Expire stored content on your schedule with
nuramesh content expire.
nuramesh db migrate [--team DIR] [--grant-to ROLE]
Section titled “nuramesh db migrate [--team DIR] [--grant-to ROLE]”Applies the pending PostgreSQL migrations and exits. It needs NURAMESH_DATABASE_URL and never
falls back to SQLite. It is idempotent and safe next to another process opening the same
database (an advisory lock). The <team> argument is required but this command does not read the
team’s files. The URL is never printed.
Upgrade safety. nuramesh db migrate --plan prints what is pending (not-additive
migrations marked) and any right the connecting role lacks, and changes nothing. While a
not-additive migration is pending, db migrate refuses unless you pass --i-have-a-backup REF or
set NURAMESH_MIGRATE_ACK to the highest pending number; the acknowledgement is recorded in the
ledger. The services (serve, worker, retention) never migrate: behind the code they refuse to
start. See Upgrade notes.
The examples ran against a fresh scratch database on a local PostgreSQL 16 (dropped afterwards):
$ nuramesh db migrate --team my-teamschema at version 29[exit 0]$ nuramesh db migrate --team my-teamschema at version 29[exit 0]The version number is the schema version of the build you run. Back up and stop old processes before moving to a newer schema (Upgrade notes).
Without the variable:
$ nuramesh db migrate --team my-teammigrate needs NURAMESH_DATABASE_URL (it never uses SQLite)[exit 2]If the database cannot be reached, it exits 1 with couldn't migrate the database: ... and the
error class, never the URL.
--grant-to ROLE
Section titled “--grant-to ROLE”After the tables exist, gives that service role its least-privilege rights (the role owns nothing; ledger tables stay append-only for it). Run it as the table owner. Its name must be a plain lower-case name (the example used a role created beforehand in the scratch database):
$ nuramesh db migrate --team my-team --grant-to docs_cli_svcschema at version 29[exit 0]$ nuramesh db migrate --team my-team --grant-to "Bad Role"--grant-to needs a plain lower-case role name[exit 2]If the grants cannot be applied it prints couldn't grant to <role> (<error class>) and exits 1.
nuramesh content expire [--team DIR]
Section titled “nuramesh content expire [--team DIR]”Deletes stored content whose retention has passed, never for an organization on legal hold, and
writes one content.expired ledger entry for each organization with counts only. A run does this
itself while it works; this command is for a store with no run active (cron, or by hand).
It also finishes an erasure of a person’s content that a legal hold put off: once the hold is lifted
the rows marked for that person are deleted and one content.erased entry is written (counts and
kind names only, deferred: true, actor system). If that step fails for an organization the
failure is logged and recorded as a system ledger entry (the error class only) and the command
carries on with the expiry; the rows stay marked and the next run retries.
$ nuramesh content expire --team my-teamexpired 0 content record(s)re-captured 0 configuration(s) before expiry[exit 0]With NURAMESH_DATABASE_URL set it works on PostgreSQL; otherwise on the SQLite store. It does not
read the team’s configuration. A content store that is not available is exit 2
(the content store isn't available: ...).
Related commands that already have a page
Section titled “Related commands that already have a page”| Command | Page |
|---|---|
nuramesh content shred, nuramesh keys status, nuramesh keys reconcile, nuramesh keys adopt-legacy |
CLI reference |
nuramesh otel check / export / rotate-pseudonym-key |
OpenTelemetry export |
nuramesh ledger export and nuramesh_verify.py |
Auditor guide |
nuramesh org, roles, breakers |
Stop an organization, a role or a rule |
nuramesh agents credentials |
Agent credentials |
Check it worked
Section titled “Check it worked”nuramesh db migrate prints schema at version N and exits 0, and a second run prints the same line and changes nothing. Then nuramesh ledger verify --team <team> exits 0.
Troubleshooting
Section titled “Troubleshooting”| You see | Do this |
|---|---|
migrate needs NURAMESH_DATABASE_URL (it never uses SQLite) (exit 2) |
Set the variable. A SQLite store migrates by itself when a new version first opens it |
couldn't migrate the database: ... (exit 1) |
The database cannot be reached. The message has the error class, never the address |
db migrate refuses to run |
A not-additive migration is pending. Take a backup, then pass --i-have-a-backup REF or set NURAMESH_MIGRATE_ACK |
| A service refuses to start | The schema is behind the code. Services never migrate: run nuramesh db migrate |
Next steps
Section titled “Next steps”- Upgrade: the notes for each migration.
- Back up and restore.
- Content store and retention.
Was this page helpful?