Coupled Transactions
7 minute read Published:
After several iterations of trial and error, I write code to update two databases while keeping them in sync.
Background We’re writing an application in Typescript. We have two Postgres databases that we want to keep in sync for the tables that they have in common. I’ll refer to them as our main database and our synced database.
The synced database contains all the tables that our main database has plus other tables that our application won’t be touching. We want to update the main database live while keeping the synced database identical.