DEV Community

Cover image for The Day Everyone Turned Into Michael Johnson. A Lesson In F5.

The Day Everyone Turned Into Michael Johnson. A Lesson In F5.

Adam Barker on April 15, 2018

There is no real point to this article - it’s not one of my usually strong lectures and doesn’t feature a key take-away or call to action. It’s ju...
Collapse
 
moopet profile image
Ben Sinclair

I did exactly the same one time, where I used to be "careful" by writing everything as SELECTs first before changing them to UPDATEs, making extensive use of the command-line history. I ended up writing UPDATE users SET first_name='Martin'; WHERE user_id=12345. Clever me and my semicolons. It replicated 10,000+ changes to 300+ other sites and took down the whole system in short order. I tell that story in interviews when they ask for nightmare stories.

Collapse
 
helenanders26 profile image
Helen Anderson

Wow, that's one heck of a story!

Collapse
 
lluismf profile image
Lluís Josep Martínez
  1. Never use autocommit with SQL interpreters. After the UPDATE you probably will see the number of rows updated. If it's not 1 rollback, otherwise commit.

  2. Always keep a historic table for each important entity of your system.