Hi all,
I’m confused about how migrations work. I’ve been using them for a
couple of weeks but haven’t had any serious rollback issues yet. Just
now I added a field to a table with a migration and ran “rake migrate”,
which added the field as expected.
This was in the file db/migrate/007_mymigration.rb, making it version 7.
Later I changed my mind and decided to rollback to the previous schema,
so what I entered was
rake migrate VERSION=006
…which proceeded to drop all the tables in my database.
Now what I’d like to happen is (a) to understand why that happened, and
(b) to be able to run “rake migrate” and have it consecutively run each
migration 001 through 006 in turn and update the database.
I’ve tried running “rake migrate” again, thinking it would bring
everything up to date, but it seems the only migration it ran was 007,
which failed because the relevant table doesn’t exist.
I even deleted the schema_info table, thinking that Rails would
re-create and start at migration 001, but it behaved the same way.
What am I missing? Is this the correct behavior and I’m doing something
wrong? Fortunately this was on my development database where all I lost
was some test data.
Thanks,
Jeff