Skip to main content

Module setup

Module setup 

Source
Expand description

Setup command and connection validation for deployment tracking infrastructure.

Provides three concerns:

  • setup() — Idempotent, self-healing creation of the _mz_deploy database, tables, views, indexes, and (when RBAC is enabled) roles. The only function that writes to _mz_deploy. Invoked exclusively by the explicit setup CLI command. When RBAC is enabled, must run as a superuser: phase 4 issues GRANT ... ON SYSTEM statements (CREATEDB, CREATECLUSTER) that only a superuser can execute under RBAC. When RBAC is disabled, the role/grant phase is skipped entirely. Safe to re-run.
  • verify() — Read-only existence check. Every non-setup command calls this and surfaces CliError::SetupRequired if the infrastructure is missing or partially installed. Never writes.
  • validate_connection() — Pre-flight checks that the connected role has exactly one mz-deploy role membership.
  • run() — The setup CLI command entry point.

Enums§

MzDeployRole
The mz-deploy role assigned to the current database user.

Functions§

is_rbac_enabled
require_createdb
Verify the current role has CREATEDB privilege. mz-deploy dev calls this before attempting to create overlay databases.
require_deployer
Require that the validated role is Deployer.
require_developer
Require that the validated role is Developer.
run
Initialize deployment tracking database and tables.
setup
Bring the deployment tracking infrastructure up to the current schema.
validate_connection
Validate that the current role has a valid mz-deploy role membership or is a superuser. Returns the detected role on success.
verify
Check that every object setup would create is already present.