Possible to recover data from log/development.log files?

Hey all. Seems I've found a bug in Rails db:migrate - maybe it is,
maybe it isn't. If possible - I'd appreciate some help recovering from
it.

Apps, OS, etc.:
MySQL: Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using
readline 5.1
Rails: 2.3.8,
OS: CentOS 5.4 updated as of this past weekend

Long story made short. I have a rails app in development mode with a
significant amount of data. I created a couple migrations to add a
couple columns and remove a couple more. After my first attempt to run
the migrations, I realized I'd made a mistake and attempted to revert my
changes with a 'rake db:migrate VERSION="<name of migration>"'.

Mistake #1: Oops. I typed the name of my migration incorrectly, and it
reverted to... wait for it... VERSION="0". That's the "bug" part - (I
don't think) it shouldn't be reverting to VERSION="0" whenever it has an
error or fails to find a migration... No, I didn't have an environment
variable VERSION="0".

Mistake #2: My bad - I didn't back up the database before applying my
changes. 05:30 AM + "meh - simple column change, what could happen..."
=~ poop.onstick()

log/development.log seems like it contains all the INSERT INTO actions.
(crosses fingers) Has anyone ever used the log file to recreate the
database..? Am I missing something: is there a better way?

Any help, input, or ideas beyond "you should have backed up your DB"
would really be appreciated.

Thanks,

Andrew Vliet
1 403 667 3201 (c)
1 403 648 0627 (w)

If you haven't cleared out your log along the way, you should be able to
parse through that and reconstruct your inserts.

I know I periodically 'archive off' my development.log
(development.log.thru.20100617 anyone?) just so I have a record
(especially when trying to diagnose issues).

Ar Chron wrote:

If you haven't cleared out your log along the way, you should be able to
parse through that and reconstruct your inserts.

I know I periodically 'archive off' my development.log
(development.log.thru.20100617 anyone?) just so I have a record
(especially when trying to diagnose issues).

Hmm. Perhaps instead of doing that, you should just put your
development.log in version control? (I confess that I've never needed
an archive such as you describe.)

Best,

A little late, but another reason 'the rails way' encourages separate
dev and production databases. You will get better performance running
under production mode too