Skip to content

Add postgres storage adapter for samod#962

Merged
epatters merged 1 commit intomainfrom
postgres-storage-adapter
Jan 27, 2026
Merged

Add postgres storage adapter for samod#962
epatters merged 1 commit intomainfrom
postgres-storage-adapter

Conversation

@jmoggr
Copy link
Collaborator

@jmoggr jmoggr commented Jan 26, 2026

I shipped the Samod integration without it ever touching our DB?! Yup, this is equal parts embarrassing and amusing while also being a surprisingly small issue.

Thanks to the decentralized nature of Automerge we can largely get by without persistence on the server. Documents are synchronized with the server on connection from the browser local storage. So unless the user changes browsers, computers, or clears their browser cache, nothing would ever appear wrong.

Besides missing InMemoryStorage, how did I miss this? Because I often have both Firefox and Chrome open when testing/debugging/developing, so when I cleared the browser cache from one with the server shutdown, the open documents were effectively restored from the other browsers cache as soon as the server started again. The problems really started when trying to use the staging database locally.

The storage adapter tests were re-written from the automerge-repo typescript, I'm going to try getting them upstreamed. I opened an upstream PR here


backend startup has changed. Samod tries to read from the database on initialization and will error if the migrations have not run. Now backend blocks until the migrations are complete instead of using a status gate.

The status gate gave us the ability to run long migrations without worrying about the systemd service timing out on startup. However continuing to support it would increase complexity by a non-trivial amount. Removing it simplifies things and will automatically fail the deployment if the migrations fail.

@github-actions github-actions bot temporarily deployed to netlify-preview January 26, 2026 13:46 Destroyed
@jmoggr jmoggr force-pushed the postgres-storage-adapter branch from 9f74c9d to fa82549 Compare January 26, 2026 15:36
@github-actions github-actions bot temporarily deployed to netlify-preview January 26, 2026 15:36 Destroyed
@jmoggr jmoggr force-pushed the postgres-storage-adapter branch from fa82549 to 6ff39ef Compare January 26, 2026 15:42
@github-actions github-actions bot temporarily deployed to netlify-preview January 26, 2026 15:42 Destroyed
@jmoggr jmoggr added bug Something isn't working backend Backend, including web server and database labels Jan 26, 2026
Copy link
Member

@epatters epatters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, I guess our app being mostly local-first means that it mostly works without a persistent storage ;)

This looks great. And thanks all for trying to upstream the storage adapter tests.

@epatters epatters merged commit 6b81004 into main Jan 27, 2026
19 checks passed
@epatters epatters deleted the postgres-storage-adapter branch January 27, 2026 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend, including web server and database bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants