Expand description
Per-user database provisioning.
Each user owns a dedicated Postgres database, reached via userpool from
the users.db_name DSN. This module creates that database, brings it up to
the (DDL-only) schema with the shared migration set, and returns its DSN so
the caller can persist it in users.db_name.
Provisioning reuses the admin DATABASE_URL connection — Postgres allows a
connection to create a different database — so no separate maintenance DSN
is required. The only prerequisite is that the admin role holds CREATEDB.
Functions§
- create_
user_ database - Creates and migrates a dedicated database for
user_id, returning its DSN. - drop_
user_ database - Drops a user’s database, used as compensating cleanup when a step after
provisioning (e.g. the
usersrow insert) fails and would otherwise orphan the just-created database. Best-effort and idempotent (IF EXISTS). - store_
user_ private_ key - Stores a user’s RSA private signing key into their (already-provisioned)
per-user database at
dsn. The private key never leaves that database.