Description
One-Shot Self-Host Initialization takes an empty PostgreSQL target to a bootable Dots workspace. The provisioner applies schema migrations, prepares storage, creates or adopts the first owner identity, seeds the workspace company, creates the foundational Dotabases, and binds the owner through the Access authority plane. It runs out of band because the normal server boot guard expects an existing company before serving.
The operation is idempotent: rerunning migration and provisioning adopts existing owner/company state and skips already-created foundational data rather than duplicating it. The public dots init command supplies non-interactive owner flags and environment fallbacks, plus a migration skip for release processes that own schema application separately. A first-signup mode can intentionally stop after schema and storage setup, leaving the first browser signup to claim ownership. Typed failure codes distinguish configuration, migration, storage, identity, and provisioning faults.
Selling Points
- Replaces a multi-step database bootstrap runbook with one repeatable operation.
- Produces a real owner, company, foundational knowledge stores, and authority bindings rather than only creating tables.
- Supports both administrator-supplied owner credentials and a first-signup-becomes-owner deployment.
- Is safe to rerun, simplifying container restarts and infrastructure automation.
- Emits distinct failure categories so operators and supervisors can respond to the actual failed stage.
User Story
An administrator provisions a Postgres database for a private Dots server and runs the init command with owner credentials. The command migrates the schema, prepares storage, creates the owner and workspace, seeds the foundational Dotabases, and reports what was created or adopted. The administrator can then start the API and sign in to a usable instance instead of facing an empty schema.
Extension Surface
This feature is automatable. packages/cli/src/commands/init.ts exposes the supported command workflow, while packages/api/src/init/core.ts exports runInit with injectable production seams and deterministic reports. Deployment automation can run it repeatedly through the CLI or process entry. The ordered provisioning contract is fixed core and does not expose third-party bootstrap-step registration.
Capabilities & Limits
- Migrates schema, provisions storage, creates/adopts owner identity, company, foundational Dotabases, and Access authority.
- Supports owner-full and ownerless first-signup modes.
- Returns an idempotent created/skipped report and typed failure exit codes.
- Limit: it provisions one deployment’s first workspace; ongoing workspace creation uses normal application flows.
- Limit: a production run still requires valid database, identity, storage, and security configuration.
Implementation Map
packages/api/src/init/core.tspackages/api/src/init-entry.tspackages/api/src/init/index.tspackages/cli/src/commands/init.tsdots initpackages/cli/src/program.ts