Today Brazilian social networks have dawned on one of those news that seem like a bad joke …
16 thousand retirement process were deleted from the database of the State of Amazonas Court of Auditors (in Portuguese TCE Amazonas= Tribunal de Contas do Estado do Amazonas) due to improper execution of a script.
This leads us to think of several faults. Understand that I don’t want to judge the professionals work, it isn’t up to me this task, but I think it’s important to take some lessons from this episode…
NEVER run any script direct in the production environment! In every company there is a test environment or a test database, which is where you will test your scripts before running in the productive environment.
WHERE is life !!! ALWAYS you will write a DELETE command or an UPDATE command, write the condition first and then after write the command. The probability that you need to change or delete all records in your database is almost nil.
Use transactions. Whenever you create a script that contains UPDATE and DELETE, create a transaction. If you don’t know about transactions see my blog post about it (click here)
If WHERE is life, backup is resurrection! (thank you Paulo Camargo for the excellent phrase! He said this at my Facebook page )
All database types have backup tools, whether native or third-party tools exist and should be used! More than that, you need to have an effective backup strategy. For example, one total backup per week and incremental backups N times per day. If any problems occur the data can be restored. In the TCE case, if the backup strategy was more effective the unavailability of the system would be infinitely shorter!!!
“With great power comes great responsability”*. Are you ready?
If you want to know more about what happened…
* Uncle Ben (Spider Man)
** Tks Raul Chavarria!!!
If you liked, share this post! And if do you have any questions talk to me!