Files
Docwell/Database
tajniak81andClaude Opus 5.5 7f09338b60 Send PocketBase's auth emails in the recipient's language
PocketBase keeps one set of email templates on the users collection, so
before docwell-server asks it for a verification, password-reset or
magic-link email, the new authmail package writes the templates in the
recipient's language (stored locale, else the request's), one send at a
time. Adds Polish, German, French and Spanish templates; English stays in
the schema snapshot. New-login alerts use the language written last.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 11:39:58 +01:00
..
2026-11-17 10:21:57 +01:00

Database schema

docwell-db is a stock PocketBase: the stack runs tajniak81/pocketbase-docker-root (source) as it is. There is no Docwell image for it any more. docwell-server brings PocketBase up to Docwell's schema itself, every time it starts (Server/internal/pbschema): missing collections and fields are created, existing ones keep their data. It also writes the DOCWELL_* settings (app name and URL, mail, file storage) and sends Docwell's own emails, so PocketBase needs no hooks either. PocketBase's auth emails (verification, password reset, magic link) use the templates on users; docwell-server rewrites them in the recipient's language before each send (Server/internal/authmail), so edits made to them in the PocketBase dashboard do not last.

This folder is where that schema is written:

  • pb_migrations/ holds the JS migrations, the source of truth for the schema.
  • export-schema.sh turns them into Server/internal/pbschema/schema.json, the snapshot docwell-server embeds and applies.
  • All collection API rules are null, so only superusers have access. Never expose PocketBase publicly; only docwell-server talks to it.

Changing the schema

  1. Add a migration to pb_migrations/ (pocketbase migrate create "add_comments" --migrationsDir ./pb_migrations, or copy an existing file). Leave earlier migrations alone.

  2. Regenerate the snapshot (needs Docker and Go):

    sh Database/export-schema.sh
    
  3. Commit the migration and the new schema.json together. go test ./internal/pbschema checks the snapshot.

Removing a collection or a field is not done by the snapshot: it only adds and updates. Do that by hand, once, in the PocketBase dashboard of each install, after the release that stops using it.

The admin panel manages two parts of the users collection itself, the OAuth2 providers and the magic link switch (otp.enabled), so the snapshot leaves them out and they keep whatever is set.

Run locally

Download PocketBase v0.40.6 for your OS into Database/bin/, then:

./bin/pocketbase superuser upsert admin@docwell.test devpassword123 --dir ./pb_data
./bin/pocketbase serve --dir ./pb_data --http 127.0.0.1:8070

Start docwell-server against it (DOCWELL_PB_EMAIL and DOCWELL_PB_PASSWORD set to that superuser) and it creates the collections. The PocketBase dashboard is at http://127.0.0.1:8070/_/.