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.
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.
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.
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.