I’m a newbie in Rails and I’m trying to deploy my first project.
I’m using rails 3, ruby 1.8.7, Passanger, Mysql and Git
I followed a lot of tutorials to learn about deploying with capistrano and there is a question that i can’t figure out.
In the tutorials they never talk about schema.rb
If this file is the responsible for the migrations that i already done and when we deploy the application, capistrano copy all files to the “current” folder (schema.rb to), how can it do the right migrations on production server. Should i tell capistrano to make a simlink to the right schema.rb file for the “current” folder? if yes how can i do that?
Tnks.
The schema.rb file contains the database definition. It is not responsible for any migration.
The migrations are contained in the
db/migrationsfolder. When you deploy a new release and ask Capistrano to migrate the current database, Capistrano invokesrake db:migrate. The migrate task doesn’t rely on theschema.rb. It connects to the database, reads the list of executed migrations from theschematable and execute all the files in thedb/migrationsfor which a record doesn’t exist in that table.The
schema.rbfile is only used when you invokerake db:schema:loador when you bootstrap Rails. In the latter case, Rails will use the schema to prevent inspecting the database structure every time you access a Model.That said, the
schema.rbfile must be versioned in your SCM and you have to include it during deployment. You don’t need to do anything special. Capistrano checkout the file from your SCM like all the other files, unless you ignored it.