Respect your production data


I read yesterday this blog post: I Accidentally Deleted All Our Data by Taylor Fausak. Probably you’ll end with the same expression in your face that I did. An a palm covering it.

Something in advance. It takes GREAT courage and openness to tell in your blog this story. I think is really a great attitude about it.

Saying this, I must say that the whole story a recipe for disaster. Lots of steps make my spider-sense to tingle. Strongly.

Doing a script on the python interactive shell to update your production data, while in a convention, between presentations… Well, it’s not the right moment to do ANYTHING that could change your data. A quick look a monitoring tool, that’s grand. But anything more complex that that is highly risky. And specially using the interactive shell.

You have to RESPECT your production environment and data. Ideally, every change in production should be automated and tested before in advance. That means everything but the most extreme cases, like bugs that are blocking the whole application. Sometimes, in extraordinary cases, could necessary to take extraordinary measures. But it should always be treated with the proper caution.

You have to set all your attention each time you have to change anything on production and have a clear view in advance of what are you trying to do. Think really carefully what are you going to do. And double check everything you type. Every step that has not been previously tested on a staging environment is a possible disaster for your application.

Anyway, stories like that only make me remember how much attention should I put into changing production data and keep a healthy fear of what could happen. Treat your production environment with proper R-E-S-P-E-C-T or it can bite. Hard.

Bonus: Really, really, REALLY the best way of testing that something works is SAVING everything AGAIN????????

This code give me nightmares…


from mongoengine import connect
from models import Family
connect('the-production-database')
for family in Family.objects:
   family.save()