8. Changing live data · The story

The story

A busy week of requests against a database that now has real users in it:

  • Product wants a view counter on posts.
  • Legal says deleted posts must be recoverable for 30 days, so "delete" can't really delete any more.
  • A user wants their username changed.
  • An account is posting spam and has to go, along with everything it touched.
  • And last Friday, a teammate ran an UPDATE without a WHERE on staging and unpublished every post on the site.

So far you've only added rows and read them. Now you're changing and removing them, where a mistake hits every row at once.