How To Do Zero-Downtime Database Releases / by Chris Shaffer

Most teams at this point know how to update web applications without downtime. Few know how to update the databases behind them, though, without at least a little.

If you need help developing a strategy and/or implementing it, contact info@scoutcorpsllc.com

"Account access will be temporarily disabled from Friday evening, September 1, 2023, through Monday afternoon, September 4, 2023"
(email sent to E*Trade customers today, related to their acquisition by Morgan Stanley)
Not to pick on them too much (see numbers 7-8) ...

There are a few rules of thumb:

1) Make schema changes / migrations backwards compatible
2) Make database changes, THEN app changes
It's way easier to make a database update that does work with an old version of your app than to make an app that will work with a future schema. (think "old app doesn't need new column but won't break if you add it" versus "release new app that works even if it goes out before the column exists)

3) Don't be afraid to do multiple releases
If you've written queries that will break with a new column, fix them in a silent pre-release. If you're dropping columns, you can do it in a later "clean-up" release.

4) Test builds are a dress rehearsal
You're testing the release process, as well as the finished code. Pause to QA between steps of your test build.

5) Build and data migration scripts must be idempotent (re-runnable)
6) If you're migrating from one table / database / service provider to another, re-run your data migrations continuously throughout the release

Don't be afraid of using triggers, views, or even an independent service that polls to keep your old and new schema in sync.

Relationship Science was doing these 10 years ago.

Capital IQ (now part of S&P Global) was doing it 15 years ago using ...
7) Read-only mode, or disabling particularly troublesome features may be an acceptable compromise
We did this because it was easier (in business terms, "we could do it now rather than after years of additional work"). It's worth noting that during weekends, holidays, and afternoons through early mornings many features of a stock trading platform are in read-only mode anyway.

Lastly,
8) Since I'm sure they have complexities I haven't considered, do these outside of business hours regardless
You can always send a message saying there's a "maintenance window" and "certain features may be temporarily disabled" - let customers be pleasantly surprised!