Files
Docwell/Database
tajniak81andClaude Opus 5.5 9d674e9699
CI / go (Media) (push) Successful in 14m33s
CI / go (Server) (push) Failing after 23m30s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 9m30s
CI / desktop (ubuntu-latest) (push) Successful in 1h21m24s
CI / mobile (push) Failing after 4m16s
CI / docker (push) Successful in 1h1m25s
Docs / build (push) Successful in 14m59s
Docs / deploy (push) Skipped
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
Add invite links with approval, sharing switches, page views and unused-file cleanup
Phase G of docs/AFFINE.md (ADR-17):

- Invite links: one per workspace (member or guest, optional end date,
  optional admin approval) on a new /join page. Requests are approved
  (optionally as another role) or declined from workspace settings;
  join_request, join_approved and join_declined notifications reach the
  inbox, phones and the email digest. Workspace admins decide, else the
  organization's admins, else superadmins. Signup honours ?redirect=.
- Workspace switches: allowSharing (off makes every share link answer 404
  until it is back on) and urlPreview (chat apps may show private pages'
  titles). docwell-web writes title and Open Graph tags for known
  link-preview bots, asking docwell-server via DOCWELL_PREVIEW_API_URL;
  search engines are left out.
- Page analytics: page_views counts opens per page, person and day from
  the existing visit call and share-link reads; editors see totals, a
  daily chart and recent viewers in the Info panel. analytics.prune
  drops rows after 400 days.
- Unused files: attachments whose id appears in no page's Yjs state,
  page icon or comment (older than a day) are listed and deleted from
  workspace settings.
- Migration, schema snapshot, OpenAPI, generated clients, translations
  in five languages, phone inbox, compose files and user docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 15:59:55 +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.

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/_/.