capistrano,:db角色,目的是什么? [英] capistrano, :db role, what's it for?
问题描述
据我所知,capistrano :db
角色仅用于运行迁移。
As far as I can tell, the capistrano :db
role is used only to run migrations.
(因此,在大多数情况下,不应实际上是运行数据库的服务器。为什么会有ruby / rails在那里堆叠(或允许ssh登录)?这就是您要实际执行rails迁移的任何服务器)。
(Thus, in most cases it probably shouldn't actually be the server that runs your database. Why would you have a ruby/rails stack there (or allow ssh logins there)? it's just whatever server you want to actually execute the rails migrations).
只有标识为的数据库角色的服务器:primary => true
用于运行迁移。
And only the server identified as db role with :primary => true
is used to run migrations.
因此,任何其他服务器被标识为 db角色,但没有:primary =>真的
...什么都没用?那么,为什么 capify创建的默认deploy.rb鼓励您列出它们呢?
?您甚至会在这里列出什么?
So any other servers identified as 'db' role but without :primary => true
... are used for nothing at all? So why does the default deploy.rb created by capify .
encourage you to list them? What would you even list here?
我丢失了什么?
推荐答案
显然,角色:db
的名称具有误导性。正如您所指出的,Capistrano将其定义为主机(使用:primary => true
)作为我们执行 rake db:migrate $ c的主机$ c>,但是数据库服务器并非始终在此类主机上运行。我们可以通过Rails应用程序更改远程数据库服务器的架构。此类主机的正确角色名称不是
:db
。
Obviously, the name of role :db
is misleading. As you pointed out, Capistrano defines it (with :primary => true
) as a host that we execute rake db:migrate
on, but database servers are not always running on such hosts. We can alter the schema of remote database server through a Rails app. The correct role name for this kind of host is not :db
.
从 lib / capistrano / configuration / roles.rb ,原始角色:db
的含义是运行数据库服务器的主机。我们应该登录到:db
主机并执行一些任务。
Inferring from the comments on lib/capistrano/configuration/roles.rb, the original meaning of the role :db
is a host on which database servers are running. We are expected to login to the :db
hosts and do some tasks.
Capistrano的设计师应该已经定义了:migration
角色或其他用于 deploy:migrate
任务的角色。但是:db
角色与此任务之间的关联是六年前通过 9a6d2fb ,此后一直没有更改。
The designers of Capistrano should have defined :migration
role or something else for the deploy:migrate
task. But the association between the :db
role with this task was defined six years ago with 9a6d2fb and has not been changed since then.
通常,Capistrano的用户可以定义角色并将其与任务关联自由地。 deploy:migrate
任务作为食谱提供给Rails开发人员。不幸的是,此食谱对我们如何进行数据库迁移存在误解,并且已被广泛使用了很长时间。
Generally speaking, the users of Capistrano can define roles and associate them with tasks freely. The deploy:migrate
task is provided just as a recipe for Rails developers. Unfortunately, this recipe includes a misconception about how we do the database migration and is used widely for a long time.
这篇关于capistrano,:db角色,目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!