ops db
PostgreSQL database user and role management. All commands connect to the wg_digests PostgreSQL database. Supports idempotent user creation, RBAC role management, and grant auditing.
Every ops db subcommand operates against the wg_digests PostgreSQL database. There is no --database flag โ connection details are sourced from environment configuration.
Subcommandsโ
| Subcommand | Description |
|---|---|
schemas | List PostgreSQL schemas |
users | List PostgreSQL users with schema access |
grants | Show a user's schema and table grants |
roles | List PostgreSQL roles and their members |
create-role | Create a PostgreSQL role (idempotent) |
add-to-role | Add a user to a role |
remove-from-role | Remove a user from a role |
audit-roles | Audit schemas for missing wasteology_admin / wasteology_readonly grants |
test-connection | Test a user's database connection and show accessible schemas |
create-user | Create a PostgreSQL user with schema access |
create-schema | Create a PostgreSQL schema |
change-password | Change a PostgreSQL user's password |
grant-schema | Grant access on additional schemas to an existing user |
revoke-schema | Revoke all access on schemas from a user |
Common Workflowsโ
Onboard a New User
create-user provisions an account with a starter role, then grant-schema adds extra schema access as needed.
Audit Permissions
roles, grants, and audit-roles together answer "who can read what" without leaving the terminal.
Verify Access
test-connection confirms a user can actually authenticate and lists every schema they can reach.
Inspection Commandsโ
ops db schemasโ
List every schema in the wg_digests database.
ops db usersโ
List PostgreSQL users along with the schemas they have access to.
ops db grantsโ
Show a single user's schema- and table-level grants in detail.
This command resolves inherited grants via pg_auth_members, not just direct role_table_grants entries. That means grants picked up through wasteology_admin or pg_read_all_data show up too.
ops db rolesโ
List every PostgreSQL role and its members.
ops db test-connectionโ
Test a user's database connection and list the schemas they can actually reach.
User Managementโ
ops db create-userโ
Create a PostgreSQL user with schema access. Idempotent โ running it against an existing user updates role assignments without erroring out.
ops db change-passwordโ
Rotate a user's password. Prompts interactively for the new value.
Generated passwords must avoid $, !, `, and \ โ these characters break in double-quoted bash strings and downstream tooling. Prefer alphanumeric + a small punctuation set.
ops db grant-schemaโ
Grant a user access on one or more additional schemas.
ops db revoke-schemaโ
Revoke all access on a schema from a user.
Role Managementโ
ops db create-roleโ
Create a PostgreSQL role. Idempotent โ re-running against an existing role is a no-op.
ops db add-to-roleโ
Add a user to a role, granting them every privilege the role carries.
ops db remove-from-roleโ
Remove a user from a role.
Schema Managementโ
ops db create-schemaโ
Create a new PostgreSQL schema in wg_digests.
Use ops db audit-roles after creating a new schema to ensure wasteology_admin and wasteology_readonly roles have the correct grants.
ops db audit-rolesโ
Scan every schema for missing wasteology_admin / wasteology_readonly grants. Highlights schemas where the standard roles do not have the expected privileges so you can repair drift.
Run after creating new schemas, after dbt model deployments that create new tables, and as part of periodic RBAC reviews.