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?