We provide a custom made service for just drop us a line.
We would be glad to have feedback from you.
Confidential — Public Healthcare · Clinical Systems
Problem
Migrating a clinical system is not one migration. The schema has to move, the procedures have to move, and the code in front of them has to move — three schedules, three risks, and only one of them can be rolled back cleanly.
The usual answer is a change-data-capture product: buy a licence, let the vendor's tool keep the two databases in step, cut over when the tool reports a zero delta. It works. It also costs a licence, adds a component nobody on the team wrote, and puts the one fact you cannot afford to be unsure about — whether a write reached both databases — behind a support contract.
The requirement here was the opposite: no additional CDC tooling, both databases written, zero data loss, and no interruption to a system that clinicians were using.
Approach
Three decisions.
Put the decision in one place. A gateway in front of both engines, exposing the same operations whichever database is behind them. Application code calls the gateway; the gateway decides where the write goes and where the read comes from. Neither database knows about the other, and the application does not know there are two — which is what makes the whole arrangement reversible.
Write both, and take the second write seriously. Database triggers plus the gateway's own CRUD path keep the two in step, with the mechanism chosen per operation. When the second write fails, the gateway does not guess: it records the failure, and the read path is built so that a partial write becomes visible rather than silent.
Design the failure path first, not last. If the call to the new engine throws, the gateway answers from the old one. If the row cannot be found in the new engine, it looks in the old. If both hold it, they are compared and only a match is returned. This is not an exception handler bolted on at the end; it is the mechanism that made it reasonable to attempt the migration while the system was in use.
Figure 1 — One access layer in front of two engines
Figure 2 — The read path, including the part designed to fail
How it was run
Infrastructure first: a new PostgreSQL estate configured for the workload before any data moved, because a migration that starts by discovering the target is misconfigured has already lost the schedule.
Schema, replication and stored procedures moved through a converter, with analysis attached to each rather than a bulk load followed by hope. The .NET integration surface was routed to Java wherever the data access had to be rewritten, and each phase produced its own report.
The gateway was proven on reads before it was trusted with writes. The proof was not a sample: it enumerated 972 tables and 143 stored procedures across 268 GB, which is the point at which “the design works” stops being an opinion.
During the parallel period both databases were written on every transaction. That is more load than the system would carry in steady state, and it was accepted deliberately — a short period of excess cost in exchange for the ability to compare.
Figure 3 — A write is not finished until both databases have it
What we delivered
Clinical system, client and data withheld. The design is described at a structural level.
Impact
No CDC licence was bought, and both databases were written for the length of the parallel period — which is the requirement, met by construction rather than by procurement.
Zero data loss was the stated requirement, and the design's answer to it is structural: a transaction is not acknowledged until both writes are accounted for, and a second write that fails is recorded rather than assumed.
The gateway stayed after the migration finished. It is now the system's access layer, which means the next database change is a change behind it rather than a rewrite in front of it — the cost of the approach was paid once and is being amortised by every change that follows.
We provide a custom made service for just drop us a line.
We would be glad to have feedback from you.