10 comments

  • leetrout 2 hours 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?

    • hobs an hour 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.

  • krystofee 13 minutes ago

    Is there any easy way to implement this pattern in AWS RDS deployments where we need to deploy multiple times a day and need it to be done in few minutes?

  • sarchertech an hour ago

    This is just the natural solution that falls out if you want to change a schema with no downtime. I always just called it “dual writing”.

  • maffyoo 30 minutes ago

    Expand Contract from Fowler's bliki

    https://martinfowler.com/bliki/ParallelChange.html

    • layer8 7 minutes ago

      Expand the interface contract and then contract the interface contract? ;)

  • fuzzy2 2 hours ago

    I’m confused. I thought Expand and Contract was about mutating an existing schema, adding columns and tables, not creating a full replacement schema. But maybe I misunderstood?

    What’s in the article, I know as the Strangler Fig Pattern.

    • jerriep an hour ago

      What you describe is what they describe as well:

      > For column-level changes, this often means adding new columns to a table that have the characteristics you want while leaving the current columns as-is.

      I think what makes it confusing is that their diagrams depict a completely separate schema, but what they describe is really just altering the existing schema.

    • DeathArrow an hour ago

      > What’s in the article, I know as the Strangler Fig Pattern.

      Strangler fig pattern is mostly concerned with migrating from an old software to a new software, from example from a monolith to microservices. But I guess you can also apply it to database schemas.

  • skywhopper 37 minutes ago

    This is the model we used at the SaaS I worked for a decade ago. It worked great to allow for smooth, zero-downtime upgrades across a fleet of thousands of DB servers serving tens of thousands of app servers and millions of active users.