开发者

Capistrano deploy and schema.rb

开发者 https://www.devze.com 2023-02-12 08:04 出处:网络
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'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/migrations folder. When you deploy a new release and ask Capistrano to migrate the current database, Capistrano invokes rake db:migrate. The migrate task doesn't rely on the schema.rb. It connects to the database, reads the list of executed migrations from the schema table and execute all the files in the db/migrations for which a record doesn't exist in that table.

The schema.rb file is only used when you invoke rake db:schema:load or 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.rb file 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消