9
18 Comments

I accidentally deleted my production database and it brings more user than I imagine.

On Saturday I decided that my website https://www.logname.dev is ready to be used and I posted it everywhere (Reddit, Hackernews etc).

At the end of the day, I want to see how many user actually registered. Instead of connecting to my database I run a previous command which deleted the entire database.

With a single enter all my user was gone and I have no way to get them back. Out of frustration and in need to tell those who registered to register again, I wrote this blog post https://dev.to/tehaisperlis/i-delete-my-live-prod-database-and-have-no-backup-2kp4 .

It actually got a lot of view and some of it went to see my website. I guess people like to read these "war stories".

  1. 2

    Reminds me of this video from Tom Scott,
    https://youtu.be/X6NJkWbM1xk

  2. 2

    On the first day as a junior software developer at a first salaried job out of erased all data from the company's production database.In a poll on the tech site the Register, less than 1% of 5,400 respondents thought the new developer should be fired.Steam For Linux Bug Wipes Out All of a User's Files. http://waterheateradvisors.com/

  3. 2

    As we say in Portuguese, "there are evils that come for good". Happy to see that things turned out well in the end!

  4. 1

    Lesson for the future: backup backup

  5. 1

    It's entrepreneurship roller coaster. :)

    I'm curious in which subreddit did you publish your app?

    1. 2

      I posted on sideprojects.

  6. 1

    A little trick I learned for connecting to your DB. When you first set up a DB, create a second user that has read only privileges.

    Make 2 connections to your production DB. One with the super-admin labeled something like "Production full access - NEVER USE" and one with the read only login labeled like "Production READ ONLY".

    I'm using MySql Workbench, I am sure that there are other similar tools for other DBs. Even if you are doing CLI though, make yourself a read-only account.

    Doing that will save you a lot of future heartaches.

    I made the mistake one time of accidentally deleting the production DB, thinking I was resetting my local because I left the tab open. Luckily, production was basically empty at the time. Now, if I absolutely have to log into production with write privileges, as soon as I am done, I close the tab so that I can't do something by mistake by leaving it open. It is rare that I need write privileges in production. Keeps me from being able to do anything by accident. I use the read only account for day to day status checks. The big bold "NEVER USE" in the label does actually keep you from being careless.

  7. 1

    When working from on a production database and you need to write a delete query, start by creating it as a select. When its ready, turn it into a delete query and run the query. Right after the query executes, turn it back into a select query unless you plan on removing it or running it immediately again. Don't wait, do this right after the query runs. This way you will never forget and things like this can't happen. Moral of the story is: Leave no delete query behind. But same goes for other potentially dangerous queries like update and truncate, with these just comment them out when you're not running them.

  8. 1

    Always, always have a 2FA-type prompt before doing super destructive command.

    Want to delete all users? What's 42 + 17.
    Want to delete the entire database? What's 32-7.
    Etc.

    1. 1

      That’s a nice concept, but I don’t see how that’s really possible when connecting and doing something like DROP DATABASE MyDatabase; doesn’t require more than the enter key.

      1. 1

        Well, for one, we NEVER connect directly to the DB. You always connect through a proxy/app. So you would never be running queries directly in psql, or whatever. But if the user @valehelle did confirm already, this wouldn't have helped anyway.

      2. 1

        Yeah exactly. To be fair to Heroku they did warn me about it and I had the option to reply the prompt to confirm or to confirm from the command line which unfortunately I did with this line --confirm <app-name>

  9. 1

    Something like this had happened to me. I had a Discord server with 200 members. I deleted it while updating. Then I sat down and cried. 😂😅

    1. 1

      Awh man. I almost did too be honest. The only reason I did not is because that it's my personal website and not my company!

  10. 1

    Oooof. Not fun. I bet you learned some research into good database backup solutions after that though!

  11. 1

    you get lucky :D

    btw, for this landing page, it would be nice to show how this product actually looks like. I might be interested in, but I don't want to register just to see if that's what I want

    1. 1

      Thanks for the tip. It's in my next to do list :D

Trending on Indie Hackers
How I grew a side project to 100k Unique Visitors in 7 days with 0 audience 47 comments Competing with Product Hunt: a month later 33 comments Why do you hate marketing? 27 comments $15k revenues in <4 months as a solopreneur 14 comments Use Your Product 13 comments How I Launched FrontendEase 13 comments