leetrout
3 months ago
I use this example when I speak about and teach devops trainings.
I call it the migration sandwich. (Nothing to do with the cube rule).
A piece of bread isn't a sandwich and a single migration in a tool like alembic isn't a "sandwich" either. You have a couple layers of bread with one or several layers of toppings and it's not a sandwich until it's all done.
People get a laugh out of the "idiot sandwich meme" and we always have a good conversation about what gnarly migrations people have seen or done (72+ hours of runtime, splitting to dozens or more tables and then reconstructing things, splitting things out to safely be worked on in the expanded state for weeks, etc).
I had never heard it called "expand and contract" before reading this article a few years ago.
What does everyone else call these?
tczMUFlmoNk
3 months ago
I have usually heard it called "A–AB–B migrations". As in, you support version A, then you support both version A and version B, then you support just version B.
The rest of the sequencing details follow from this idea.
mayanraisins
3 months ago
I’ve always paired this with the strangler pattern.
“In programming, the strangler fig pattern or strangler pattern is an architectural pattern that involves wrapping old code, with the intent of redirecting it to newer code.”
mcdonje
3 months ago
This is the same pattern as versioning, but with an extremely short sunset for the old version.
afiori
3 months ago
That is a very reductionist view and not particularly useful either. It shares elements with versioning and you could likely implement this using explicit versioning, but it is completely independent of it.
The main difference I see is that of focus here the focus is to migrate a database without downtime or excessive global locks, keeping multiple versions of the schema is a detail.
mcdonje
3 months ago
Seems like you agree with my assessment.
afiori
3 months ago
:(
Things can have similarities without being the same. Also not being unique is not a moral failure.
I think I am failing to understand your stance.
mcdonje
3 months ago
Saying the pattern is the same isn't the same as saying two things fitting the pattern are the same in every respect.
Patterns are necessarily reductionist, like any sort of comparison of things that aren't 100% similar.
There is value in recognizing patterns. They're useful for comprehension and memory.
marcosdumay
3 months ago
It's actually not.
Versioning is a concept where each version lives in non-intersecting time intervals.
This concept is completely focusing on the fact that your structures lifetimes must absolutely have non-empty intersections. It's close to the opposite.
chrisweekly
3 months ago
> "Versioning is a concept where each version lives in non-intersecting time intervals."
Is it? Node.js publishes "Current", "LTS" and "Maintenance" versions, and there's always a reasonable time interval during which consumers typically upgrade from eg Maintenance to newer LTS or even Current. From the publishing side, that's very similar to "expand and contract", in temporarily expanding what's supported to include Current, and dropping support for oldest versions leaving Maintenance. It's continuous instead of ad hoc, and there are more than 2 versions involved, but the principle is basically the same (at least if you squint).
Though I guess if you're talking strictly about schema management strategies, then yeah, "versioning" might be very different from "expand contract", as you noted.
UltraSane
3 months ago
It is often necessary to use multiple versions at the same time
hobs
3 months ago
To me is just a blue-green type deployment for schemas. You have an old and a new thing, you split and merge as traffic replays to the new thing and shows that its viable and not breaking, you swap over as you can.
Normal_gaussian
3 months ago
Evens between odds. Where even schema versions are migrations and 'divisible between two'.
But green/blue and A/AB/B I've used before to discuss the same.