I've done this a few times in my career. I'm smart enough now to always backup before I make any potential mistakes and test everything on a staging server. The worst was executing "DELETE FROM " instead of "DELETE FROM where userid='X' on a production server.
If I were to re-imagine SQL I'd invert the sequence of the clause and statement for this very reason (FROM TABLE WHERE USERID="X" DELETE). As it, when I'm writing sensitive SQL to fix an issue I end up writing the where clause first as a SELECT, then issue it.. check the results, history up, ctl-a and replace with a DELETE. Harrowing stuff.
I Accidentally Deleted All Our Data
21–30 of 78 posts
Re: I Accidentally Deleted All Our Data
#22"We had a backup from earlier in the week" week? That seems kind of off. I'd suggest setting up backups more often than that, especially for production data. Sorry to hear about that. I destroyed a drive once a long time ago (~1994) as well. Happens to the best of us.
Re: I Accidentally Deleted All Our Data
#23Re: I Accidentally Deleted All Our Data
#24I wonder if it's possible that it was a MongoDB glitch and not a user error. From what I've read, it's notorious for randomly losing records. Maybe the loop save triggered it?
Re: I Accidentally Deleted All Our Data
#25Who works with a prod database in an interactive interpreter? My eyes are literally wide in shock.
Re: I Accidentally Deleted All Our Data
#26Re: I Accidentally Deleted All Our Data
#27Hey guys, I accidentally all of our data. Is this dangerous?
Re: I Accidentally Deleted All Our Data
#28Doesn't django let you check if models are valid without saving them?
In rails I can do:
Family.all.select {|f| !f.valid?}Re: I Accidentally Deleted All Our Data
#29Although direct database update isn't recommended in SAP, still for some strange reasons it was needed in one of the projects to modify a wrong entry done by functional consultant. One of my fellow programmer was assigned this task and this is what she did - Update set = instead of Update set = where The code was executed on development server(thankfully) and it created a big mess. Full day work of 5 guys was lost. P…
Sounds like a poor manager to me.
Agreed, sounds like an absolutely abysmal manager. As long as the developer wasn't in the habit of making such mistakes, I would have put her in charge of any future similar changes.
Re: I Accidentally Deleted All Our Data
#30I've done this a few times in my career. I'm smart enough now to always backup before I make any potential mistakes and test everything on a staging server. The worst was executing "DELETE FROM " instead of "DELETE FROM where userid='X' on a production server.
A buddy of mine showed me a cool trick to avoid this type of problem. What you do is first use SELECT to see the records in question: SELECT * from some_table where idx >= 5 Then, once you are staring at the records that came back (and are sure they are the ones you want to delete), change SELECT * to DELETE (and change nothing else) and rerun. DELETE from some_table where idx >= 5 Pretty hard to get it wrong with th…