Instatic icon indicating copy to clipboard operation
Instatic copied to clipboard

Docs/feature: no supported way to apply external database changes; editor documents silently overwrite them

Open Amay66 opened this issue 1 month ago • 0 comments

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

  1. The published site picks the change up after the next publish (the publisher reads the rows).
  2. The editor does not. It works from the Yjs documents in collab_documents (site:main, page:main:<id>). I decoded page:main:<id> and it still had the old slug while 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.
  3. 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

  1. 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.
  2. Provide a supported reset, for example bun run collab:reset [--all | <docId>...] or an admin API call that runs the relay's resetDocs for the given ids.
  3. Optionally detect divergence (a row newer than its document blob) and either reseed or warn in the editor instead of silently overwriting the row.

Amay66 avatar Oct 16 '26 08:10 Amay66