Skip to main content

Module admin

Module admin 

Source
Expand description

One-shot initialization of a target database.

gw admin init is the ONLY thing that runs DDL, and it runs against the schema-owner DSN. It applies the backend-neutral contract, the PostgreSQL mechanics beside it, records which contract the database now carries, and grants the already-created runtime role the narrow set of privileges the daemon needs.

It refuses anything that is not an empty database (a fresh epoch starts on an empty target — no import, no backfill, no adoption), with one exception: re-running against a database this same contract already initialized is a no-op, so a retried operator command is safe.

Recovery from a failed init is to drop the database and create a new one. That is deliberately the whole recovery story: a half-applied target is indistinguishable from a stranger’s, and at cutover time an empty database costs one command.

Structs§

RoleAttributes
Role-level attributes, which exist whether or not the schema does.
RuntimePrivileges
Everything the daemon checks about the credential it was handed.

Enums§

InitOutcome
What init did.
TargetState
What a candidate target database already contains.

Functions§

backend_script
The backend mechanics, the fingerprint row, and the runtime grants, as one script.
classify
Decide what a target database is, from facts already queried out of it.
init
Initialize admin.admin_database_url()’s database, or explain why not.
inspect
Read what the target database already contains.
role_attributes
Read a named role’s attributes. None when no such role exists.
runtime_privileges
Read what the CURRENT connection is allowed to do. The daemon calls this at startup and refuses to serve while RuntimePrivileges::violations is non-empty.