Docs/feature: no supported way to apply external database changes; editor documents silently overwrite them
Version: 0.0.21 (self-hosted Docker, Postgres)
Context
During a large migration I update editor-managed data with scripts and SQL (site.settings_json: style rules and files; data_rows.cells_json, slug, versions). This is a common need for bulk imports and repairs, and nothing tells the operator what is safe.
What I observed
- The published site picks the change up after the next publish (the publisher reads the rows).
- The editor does not. It works from the Yjs documents in
collab_documents(site:main,page:main:<id>). I decodedpage:main:<id>and it still had the oldslugwhile the row already had the new one. The Explorer showed the old slug and "Open live page" went to a URL that now returns 404. - When an admin tab later saved its own copy, it wrote the stale state back: 106 style rules that I had deleted in the database reappeared (621 rules instead of 590), and the old slug could have come back too.
What the code already does
server/collab/relay.ts documents that resetDocs and the row-write reset seam drop CRDT state when the backing JSON is rewritten out-of-relay by application paths ("plugin pack installs, HTTP site saves, data-workspace edits"). Direct SQL bypasses that seam, and I could not find an admin endpoint, CLI or documented procedure to reset the documents afterwards.
Workaround I use
Close all admin tabs, delete the affected rows from collab_documents (site:main and/or page:main:<id>), then restart the app container (its shutdown flush writes nothing when no editor is connected). The documents are re-seeded from the rows when the editor is opened next.
Requests
- Document this in the database / migrations docs: which tables are projections of the collab documents, that direct writes are not observed, and the safe procedure.
- Provide a supported reset, for example
bun run collab:reset [--all | <docId>...]or an admin API call that runs the relay'sresetDocsfor the given ids. - Optionally detect divergence (a row newer than its document blob) and either reseed or warn in the editor instead of silently overwriting the row.