4 ms·
It's my opinion that schema changes should be cheap, fast and unexciting. Unfortunately, in my experience once you are operating at scale they are expensive, s
by simonw 5y ago
It's my opinion that schema changes should be cheap, fast and unexciting.
Unfortunately, in my experience once you are operating at scale they are expensive, slow and fraught with peril.
The result is that engineering teams often chose to build poorly designed schemas and take on technical debt rather than make a schema change to a core table. This is a terrible anti-pattern!
I'm massively in favour of anything that makes schema changes cheaper and more boring. I really enjoy working with the Django schema migration system for this reason - though it won't help you as much if you need to make schema changes to older versions of MySQL (I've not tried schema changes against 8.0 yet) since you'll likely still need to use GitHub ghost or Percona pt-online-schema-change.
- spullara 5y agoBefore Twitter migrated off their MySQL user database there were many columns that had been repurposed for exactly this reason.
- simonw 5y agoI've been contemplating adding a JSON column to all of my tables just to provide somewhere that covers those cases - still controlled with source-code level validation and with the expectation that any column which needs to be used for filtering rows gets promoted to "real column" status. I'd much rather use a robust, performant real schema migrations tool though.
- gfody 5y agoyeah treating every schema change as a db migration might be our industry's worst anti-pattern. transactional ddl allows you to do stuff like: begin tran ..refactor data, drop/create tables.. ..create backwards-compatible views.. commit ..against a live database without risking consistency
- jjeaff 5y agoI would have very few cases where that works for me. Because I almost always need the database layer to continue to work for a time with both the old code and the new code update. Deployments usually roll out to pods a few at a time so changing the schema of a table suddenly will immediately throw errors all over the place.
- gfody 5y ago> Because I almost always need the database layer to continue to work for a time with both the old code and the new code update. that's what the backwards-compatible views are for
- iamaperson 5y agohttps://www.planetscale.com/blog/non-blocking-schema-changes https://www.planetscale.com/blog/non-blocking-schema-changes disclaimer: I work at PlanetScale
- lclarkmichalek 5y agohttps://github.com/facebookincubator/OnlineSchemaChange https://github.com/facebookincubator/OnlineSchemaChange