News for hackers. Stuff that matters.
Re:PostgreSQL and UUID as Primary Key by grey-area on Saturday July 06, 2024 @10:34AM (#40890682)
Simplest way is to keep the identifiers from DB A and increment all the identifiers from DB B by an offset. Third parties complicates things of course but internally it can be pretty simple, so maybe they just didn't have too many third parties using the IDs.
Re:PostgreSQL and UUID as Primary Key by hu3 on Saturday July 06, 2024 @10:41AM (#40890727)
That was it if I recall.

They wrote a small script with the logic involved in the merging. PKs and FKs of only one database had to be incremented by an offset of max(table.pk) + safe margin.

They did this for each table.

Once this script was tested multiple times with subsets of each database, they stopped production and ran the script against it (with backup fallbacks). A small downtime window in a Sunday.

And that was it. The databases never had to pay the UUID tax, before or after.

Re:PostgreSQL and UUID as Primary Key by laserDinosaur on Saturday July 06, 2024 @11:25AM (#40890953)
>they stopped production

Oh I see, we're talking about two entirely different worlds here, lol.

Re:PostgreSQL and UUID as Primary Key by hu3 on Saturday July 06, 2024 @12:08PM (#40891308)
Not being able to stop production database for a very short window once in a lifetime is another exceptionally rare business case.

I've seen architecture astronauts make their business pay unreasonable tech insurances by adding complexity to avoid simply pausing production for some minutes when it could have been much cheaper this way.

And from my understanding, in the case I mentioned, they chose to stop production to simplify the process. But they didn't have to.

A mixture of replication plus code changes to write in two databases could also have solved the issue.

Most business die because they can't move fast enough. Not because their production database stopped for a few minutes.

Re:PostgreSQL and UUID as Primary Key by grey-area on Saturday July 06, 2024 @12:25PM (#40891429)
Stopping production on db B isn't really a requirement, just makes it easier.