Skip to main content

seed

Function seed 

Source
pub async fn seed() -> Result<(), DBError>
Expand description

Seeds the admin database (idempotent, concurrency-safe, atomic — see the module docs and seed.sql).

After seeding, points the admin user’s db_name at this deployment’s admin DATABASE_URL (the seed leaves it empty rather than hardcoding a machine-specific DSN). The update is unconditional (compare-and-update on every boot) so that if the deployment’s DSN later changes while reusing the same admin database, the stored value tracks it rather than going stale. The WHERE db_name <> $1 keeps it a no-op write when already correct.

§Errors

Returns DBError on a connection failure or if the seed transaction fails.