Skip to main content

create_user_database

Function create_user_database 

Source
pub async fn create_user_database(user_id: Uuid) -> Result<String, DBError>
Expand description

Creates and migrates a dedicated database for user_id, returning its NAME.

The name — never a DSN — is what the caller stores in users.database_name. A DSN in that column would put a live credential in a row that any SELECT * prints; see ADR 0032.

Idempotent on the CREATE DATABASE step: a pre-existing database (SQLSTATE 42P04) is treated as success so a retried provision after a mid-way failure reuses the same deterministically-named database rather than erroring.

§Errors