i am new to rails and trying to understand the migrate feature of rake
whenever I call “rake migrate”, i understand it call all the latest
version of a given of given migrate files.
Now when these files are executed, id the #down method called and then
the #up ? or must i explicitly call the #down method from rake. If yes
how do i do that from rake ?
I experimented with rake migrate and could not update my database table
i.e. chage a field from varchar(200) to varchar(200). i had to resort to
the console commands appended (see below) for it to work.
Also say I have migration scripts of different versions say for table1
it is version 5, table 7 version 4 etc
if I run rake migrate will it run both v5 for both tables or will it run
v4 for one and v5 for the other ? This is still not clear to me…
TIA,
Tuka
C:\TDV>ruby script/console
Loading development environment.
Rake looks at your database, there should be a table there that
contains one column and one row that indicates the current version of
the database schema
Rake will then look through your migrations folder and looks at the
number in the migration file names.
For each file with a number greater than the current database schema,
rake will call ‘up’
When you are degrading to an earlier version, rake will call ‘down’
for each migration file until the database schema version matches the
migration file number.
The database only has one version number, which is the accumulation of
all the migrations up to that point. In many ways it is similar to
subversion’s revision number.
On Tuesday, April 25, 2006, at 3:05 PM, Tuka O. wrote:
Now when these files are executed, id the #down method called and then
the #up ? or must i explicitly call the #down method from rake. If yes
how do i do that from rake ?
Down method should only be called when you are migrating to an earlier
version of the schema via:
rake migrate VERSION=12
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.