Migrate problem (have to go back, then forward, to "stick")


#1

I wonder if I’m reading the various tutorials (and Agile book, version
2) incorrectly…

I make an app, and then edit e.g. by adding a new column to
migrate/002_stuff.db
and then run
rake migrate
rake db:structure:dump && cat db/development_structure.sql
but I see no change in the database.

However, the database is updated if I do
rake migrate VERSION=0
rake migrate

But isn’t one supposed just to edit the migrate/*.rb files and do
rake migrate
?


#2

dankelley wrote:

However, the database is updated if I do
rake migrate VERSION=0
rake migrate

But isn’t one supposed just to edit the migrate/*.rb files and do
rake migrate
?

When you just run rake migrate you are telling the system to run all the
migration files that are a higher number than your current db version.
If you are already at version 2 and you run rake migrate after editing
002_stuff.rb nothing new will happen. When you run rake migrate
VERSION=0 then you are resetting things so 002_stuff.rb is a newer
file(2) than your db state(0).

Matt M.
blog.mattmargolis.net