Topic: Problem with Migrations

I sat down with Rails Solutions by friendsofed last weekend I ran into a small error.  When I was using Migrations I got the understanding that if I change a migration file and then use rake db:migrate it would update the database.  But after testing this I only seemed to get it too work when the database was empty.  If tables already exist then db:migrate does nothing.  If I make a new migration it will than make those changes.  I am using Rails 2 on mysql.

Re: Problem with Migrations

Are you doing a db:migrate to the current version, changing a migration file, and then re-running db:migrate?  If so, you either have to migrate back to a version prior to the migration you changed ("rake db:migrate VERSION=X") or you can just "rake db:drop" and rebuild the whole thing with "rake db:migrate".

When you run db:migrate, it checks the version of the schema and then runs all newer migrations.  If you've changed a past migration, Rails won't check to see if they've changed.

Re: Problem with Migrations

Hmm, that makes since. I was leading to that conclusion but the book that I am reading misguided me with that.  Thanks

Re: Problem with Migrations

No problem.  We're working on our first Rails project at work and I've been loving it so far.  Coming from C#, it's definitely a completely different world and it's really fun to write develop in.

In preparation, I've read 2 Rails book: Build Your Own Ruby on Rails Web Applications and Agile Web Development with Rails (in that order).  I read the first and thought it was good, but I didn't realize how bad it was until I read the second.  I haven't read the Friends Of Ed book you're reading so I don't want to say anything negative about it, but the Pragmatic book was really good.

If you have any other questions, just let us know.  It's a great framework and I really enjoy working in it.

Re: Problem with Migrations

Well the hard thing with the Friendsofed book is the face that is outdated by one year.  Which is not bad, but I have Rails 2 on my computer.  Rails is really fun though.  I find ruby's syntax quite interesting.  I come from a php background and it feels like another world.  Down to the core it is just my love for objects that brought me to ror.