quick n00b question. If I am working on one computer on a new rails
app, commit it to SVN, and then checkout to another computer. Once I
create the database (without tables), When i run rake db:migrate, will
it run all migrations on the new computer so that the database
structure is the exact same as the original computer that I was
working on?

I guess the question here is if you move a rails app with several
migrations to another computer and run the rake script, will it
iterate through all migrations effectively creating the same database
or will it only run the last migration.


Im sure this question is retarded.

It will run all migrations that have not been ran on that computer.

Computer A has 5 migrations, and has ran them all. Computer B has only
and has ran only two. Computer A commits to the repository the other
computer B does an “svn up” and gets two more, runs rake db:migrate and
will run these two new ones as well as the one that hasn’t been run.

Just to clarify…

As a result of running migrations you’ll get a table in your db called
‘schema_info’ that has only one column (version). That table is used
to track the number of the last migration run against the DB. So, if
you check out the project on a new PC, create the DB (rake
db:create:all), and migrate, you’ll create the schema_info table with
no value in version, then run each migration in turn until you hit the
last. In the future, if you add more migrations they can also be
checked out to the other PC and db:migrate will recognize that the
current migration set has newer migration than is reflected in
schema_info and will only run the unexecuted migrations.

BTW, the actual implementation of this is scheduled for change in 2.1
(timestamped migrations) but the net result is the same.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs