feat(db): self-provision split DB roles at startup (PMS-489) #381
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/PMS-489-self-provision-db-roles"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Unify role provisioning into one env-driven mechanism identical in dev and prod. The server now self-bootstraps the split roles at startup, before connecting the request pools and running migrations, replacing both the dev
scripts/pg-init.shinitdb script and the prodmokosh-bootstrap provision-rolesCLI step.New
src/db/provision::provision_roles(called frommainbeforeDatabase::new): probes whethermokosh_migratorcan already log in and skips entirely if so, so prod can drop the admin credentials after the first boot. Otherwise it connects with the privilegedMOKOSH_ADMIN_DATABASE_URL, idempotently createsmokosh_migrator(LOGIN BYPASSRLS) andmokosh_app(LOGIN NOSUPERUSER NOBYPASSRLS), reconciles the app-role grants, and closes the admin pool immediately. It also grants the migratorCREATE ON DATABASE- the grant the oldprovision-rolesstep omitted - so migrations self-install the trusteduuid-ossp/pg_trgm/citext/pgcryptoextensions and create themokosh_authschema with no permission errors.Remove the
provision-rolessubcommand (plus its now-unusedsql_quote/quote_identhelpers and help text) frommokosh-bootstrap; the binary deletion itself is tracked in PMS-492.Delete
scripts/pg-init.shand its initdb.d mount incompose.dev.yml, drop the false "untrusted extension" comments, moveMOKOSH_MIGRATOR_PASSWORD/MOKOSH_APP_PASSWORDonto the server service, and addMOKOSH_ADMIN_DATABASE_URL(the postgres superuser) to the server env and.env.example.RLS posture is unchanged: the app role stays NOSUPERUSER NOBYPASSRLS so a missing tenant filter fail-closes to zero rows; the migrator grant change is additive.
#PMS-489