I accidentally ran rake by itself and it started shooting a bunch of things across the screen and erased my database data! I think it''s because i have prod, dev, and test all pointing to the same database. I thought i was doing full backups with mysql every night but it appears i forgot to select the schema. wow i just lost a month worth of work. is there any way to recover this? i''m running redhat linux es3. i need to undelete!! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 19, 2008, at 10:43 AM, Scott Kulik wrote:> > I accidentally ran > > rake > > by itself and it started shooting a bunch of things across the screen > and erased my database data! > > I think it''s because i have prod, dev, and test all pointing to the > same > database. > > I thought i was doing full backups with mysql every night but it > appears > i forgot to select the schema.What''s in db/schema.rb? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
George Bailey wrote:> On Jun 19, 2008, at 10:43 AM, Scott Kulik wrote: > >> database. >> >> I thought i was doing full backups with mysql every night but it >> appears >> i forgot to select the schema. > > > > What''s in db/schema.rb?# This file is auto-generated from the current state of the database. Instead of editing this file, # please use the migrations feature of ActiveRecord to incrementally modify your database, and # then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your database schema. If you need # to create the application database on another system, you should be using db:schema:load, not running # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations # you''ll amass, the slower it''ll run and the greater likelihood for issues). # # It''s strongly recommended to check this file into your version control system. ActiveRecord::Schema.define(:version => 15) do create_table "articles", :force => true do |t| t.string "title" t.binary "body" t.datetime "created_at" t.datetime "updated_at" end create_table "attributes", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end create_table "comments", :force => true do |t| t.string "title" t.string "body" t.string "username" t.datetime "created_at" t.datetime "updated_at" end create_table "compound_materials", :force => true do |t| t.integer "compound_id" t.integer "item_id" t.datetime "created_at" t.datetime "updated_at" end create_table "compound_types", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end create_table "compounds", :force => true do |t| t.integer "item_id" t.integer "compound_type_id" t.datetime "created_at" t.datetime "updated_at" end create_table "item_types", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end create_table "items", :force => true do |t| t.integer "item_type_id" t.integer "attribute_id" t.integer "attribute_secondary_id", :default => 0, :null => false t.integer "wear_id" t.integer "weapon_type_id" t.string "image_name" t.string "name" t.string "description" t.integer "rank" t.integer "level" t.string "manufacturable" t.string "hp" t.string "sp" t.string "maxhp" t.string "maxsp" t.string "atk" t.string "def" t.string "mat" t.string "mdf" t.string "spd" t.datetime "created_at" t.datetime "updated_at" end create_table "manufacture_materials", :force => true do |t| t.integer "manufacture_id" t.integer "item_id" t.integer "required_num" t.datetime "created_at" t.datetime "updated_at" end create_table "manufactures", :force => true do |t| t.integer "item_id" t.integer "tool_id" t.integer "make_num" t.integer "make_time" t.datetime "created_at" t.datetime "updated_at" end create_table "tools", :force => true do |t| t.integer "item_id" t.integer "parent_id" t.datetime "created_at" t.datetime "updated_at" end create_table "users", :force => true do |t| t.string "login" t.string "email" t.string "crypted_password", :limit => 40 t.string "salt", :limit => 40 t.datetime "created_at" t.datetime "updated_at" t.string "remember_token" t.datetime "remember_token_expires_at" end create_table "weapon_types", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end create_table "wears", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Scott Kulik wrote:> > I think it''s because i have prod, dev, and test all pointing to the same > database. >Ouch!!! And whatever possessed you to do that! I assume you''ve verified that it really is gone, with MySQL admin or command line or something if you aren''t using MySQL... The database is easily constructed from your migrations. Your data, however, is another story... bit bucket heaven I fear. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
What were you backing up? On Jun 19, 12:59 pm, Ar Chron <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Scott Kulik wrote: > > > I think it''s because i have prod, dev, and test all pointing to the same > > database. > > Ouch!!! And whatever possessed you to do that! > > I assume you''ve verified that it really is gone, with MySQL admin or > command line or something if you aren''t using MySQL... > > The database is easily constructed from your migrations. Your data, > however, is another story... bit bucket heaven I fear. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 19, 2008, at 10:54 AM, Scott Kulik wrote:> ActiveRecord::Schema.define(:version => 15) doSo there''s your schema. Between that and your schema-less backups you ought to be able to piece it together. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 19 Jun 2008, at 18:03, julian wrote:> > What were you backing up? > > On Jun 19, 12:59 pm, Ar Chron <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> Scott Kulik wrote: >> >>> I think it''s because i have prod, dev, and test all pointing to >>> the same >>> database. >> >> Ouch!!! And whatever possessed you to do that! >> >> I assume you''ve verified that it really is gone, with MySQL admin or >> command line or something if you aren''t using MySQL... >> >> The database is easily constructed from your migrations. Your data, >> however, is another story... bit bucket heaven I fear.And next time, take note of the comment in database.yml: # Warning: The database defined as ''test'' will be erased and # re-generated from your development database when you run ''rake''. # Do not set this db to the same as development or production. Fred>> -- >> Posted viahttp://www.ruby-forum.com/. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 19, 5:43 pm, Scott Kulik <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I accidentally ran > > rake > > by itself and it started shooting a bunch of things across the screen > and erased my database data!The default action for rake is to run tests, so it cleared out your DB in order to load the test fixtures.> wow i just lost a month worth of work. is there any way to recover > this?The log files should still be intact, and assuming you''ve been running in development mode all this time and not cleared them, the development log should contain all the SQL statements ever generated. In theory you can extract the SQL in order to replay it with a very good knowledge of regular expressions, grep, sed, and the like. Regards, Andrew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Andrew France wrote:> On Jun 19, 5:43�pm, Scott Kulik <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> I accidentally ran >> >> rake >> >> by itself and it started shooting a bunch of things across the screen >> and erased my database data! > > The default action for rake is to run tests, so it cleared out your DB > in order to load the test fixtures. > >> wow i just lost a month worth of work. �is there any way to recover >> this? > > The log files should still be intact, and assuming you''ve been running > in development mode all this time and not cleared them, the > development log should contain all the SQL statements ever generated. > In theory you can extract the SQL in order to replay it with a very > good knowledge of regular expressions, grep, sed, and the like. > > Regards, > AndrewYes!! I still have my development log! it''s 610 megs but it does contain all the SQL statements. Now if i can just figure out how to extract them and apply them to the database....hmmm. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Scott Kulik wrote:> Andrew France wrote: >> On Jun 19, 5:43�pm, Scott Kulik <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> >> wrote: >>> I accidentally ran >>> >>> rake >>> >>> by itself and it started shooting a bunch of things across the screen >>> and erased my database data! >> >> The default action for rake is to run tests, so it cleared out your DB >> in order to load the test fixtures. >> >>> wow i just lost a month worth of work. �is there any way to recover >>> this? >> >> The log files should still be intact, and assuming you''ve been running >> in development mode all this time and not cleared them, the >> development log should contain all the SQL statements ever generated. >> In theory you can extract the SQL in order to replay it with a very >> good knowledge of regular expressions, grep, sed, and the like. >> >> Regards, >> Andrew >>Thanks for that tip. I was able to extract and parse all the SQL statements with using grep and some regular expressions in perl. I was able to recreate my main table. The only issue though is that I had a couple other tables with a few hundred records with some foreign keys to the main table which were all messed up since I did some manual database editing for some of the main entries. But, alas the site is back up and running halfway back to normal. Your suggestion saved me about 40 hours of work and a lot of other people some grief. thanks again. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> And next time, take note of the comment in database.yml: > > # Warning: The database defined as ''test'' will be erased and > # re-generated from your development database when you run ''rake''.> # Do not set this db to the same as development or production.Did someone set the db to the same as development and production? And did someone develop for a month without once writing a unit test? And is someone running a live site without a backup policy? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phlip wrote:>> And next time, take note of the comment in database.yml: >> >> # Warning: The database defined as ''test'' will be erased and >> # re-generated from your development database when you run ''rake''. > >> # Do not set this db to the same as development or production. > > Did someone set the db to the same as development and production? > > And did someone develop for a month without once writing a unit test? > > And is someone running a live site without a backup policy?yup! I just started using rails about a month ago so my knowledge in some areas is pretty limited. i guess i need to find a way to sync the test and production databases...thats the reason i was using production and development as the same database...and test unfortunately. i did however miss the the comment in the database.yml that running rake will erase the test database. i just wanted to get the syntax so i could roll back my last database migration. that''s the last time i do that! i started looking over unit tests but they looked pretty complicated on my first pass during my first week of learning rails. i did have nightly backups running...but apparently i forgot to select the schema that i ended up losing. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
my site actually is just an item database for an online game...nothing special. http://wl.kuliksco.com if you want to take a peek. so....at least i didn''t lose any production data. the scary part is that i''m a unix admin that handles the backups for all our 80 servers!! don''t tell my boss! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---