0

This afternoon I was working on my Ruby on Rails app when suddenly my development version on my laptop stopped working. It turned out the entire database had been emptied. I had a backup so it wasn't a problem but I am nervous about this happening to my online version of the app with much more important data.

What I was doing at the time that could have affected the issue: - Ran 2 migrations adding tables such as:

class AddUpdatedatesToProduct < ActiveRecord::Migration
  def change
    add_column :products, :last_image_check, :datetime
    add_column :products, :last_feed_update, :datetime
    add_column :products, :last_response_check, :datetime
  end
end

class AddRuntimeToFeedRun < ActiveRecord::Migration
  def change
    add_column :feed_runs, :runtime, :datetime
  end
end

I ran bundle update, downgraded rake gem to 10.5 (from 12). Tried to upgrade the gem rails-spec (while trying to troubleshoot a last_comment error as mentioned here). The question in case does a rake db:drop but I am quite sure I never did that.

I have confirmed by logging into postgresql directly that all tables were emptied (but the tables themselves remained).

I have nothing in my code that is even close to do any major deletions in the database. I don't have any mentions of resetting database, truncations or the likes of it. There is nothing in the code that would affect ALL tables in that sense.

My logs (that I have not accessible any longer after a reboot of my laptop during my troubleshoot) were just showing one page being loaded and then the next with errors related to the data not existing any longer. I am quite sure nothing done by actually running the web app caused it. It must have been something I did from my console.

What on earth could have caused something like this to happen? If nothing else, what commands would delete all rows in all tables?

Christoffer
  • 2,271
  • 3
  • 26
  • 57
  • You won't be able to get more than a guess, because the question lacks details (which you don't know, otherwise you wouldn't ask). My guess is some over-zealous intelligent component that wiped the data directory and ran `initdb`. Do you have some cluster management software? – Laurenz Albe Sep 06 '19 at 14:32
  • I guess you are right. It is difficult to explain ALL the things I did or how my setup is, I guess I hoped for someone who have experienced the same thing would say something like: "That happened to me, it's this or that" or "You must have run the command X or Y, those would do that to your database". – Christoffer Sep 07 '19 at 21:21

0 Answers0