防止 capistrano 在部署中迁移到 运行
Prevent capistrano to run migration in deploy
我在我的应用程序中使用 capistrano rails gem
。当我 运行 cap production deploy
它部署我的更改,同时它 运行 我的 db:migrate
和 运行 我所有的 未决迁移.
出于测试原因,我不希望它在部署后 运行 db:migrate
。
如何在部署时防止 capistrano
到 运行 deploy:migrate
,更重要的是如何查看我的 迁移状态 以查看所有我的 待定迁移 capistrano
将 运行。
对于 development ENV 中的实例,我可以 运行 rake db:migrate:status
它告诉我哪些迁移是 up
或 down
和 will/need 到 运行.
我的deploy.rb
只有namespace/function
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
end
end
desc "reload the database with seed data"
task :seed do
puts "\n=== Seeding Database ===\n"
on primary :db do
within current_path do
with rails_env: fetch(:stage) do
execute :rake, 'db:seed'
end
end
end
end
end
我的其他 deploy.rb
有所有常见的东西,例如:
set :application
、set :repo_url
、set :passenger_restart_with_touch
、set :deploy_to
、set :bundle_binstubs
、set :linked_files
、set :linked_dirs
我的版本:
Rails: 4.2.4
Capistrano: 3.5
您有两种初始化 Capistrano 的方法-Rails Gem。在您的 Capfile
中,您可以添加 require 'capistrano/rails'
,这将生成资产和 运行 迁移,或者您可以添加 require 'capistrano/rails/assets'
and/or require 'capistrano/rails/migrations'
,这将做一个或另一个,或两者都包括在内。
因此,为了避免 运行 迁移,请确保 require 'capistrano/rails'
和 require 'capistrano/rails/migrations'
不在您的 Capfile 中。
我在我的应用程序中使用 capistrano rails gem
。当我 运行 cap production deploy
它部署我的更改,同时它 运行 我的 db:migrate
和 运行 我所有的 未决迁移.
出于测试原因,我不希望它在部署后 运行 db:migrate
。
如何在部署时防止 capistrano
到 运行 deploy:migrate
,更重要的是如何查看我的 迁移状态 以查看所有我的 待定迁移 capistrano
将 运行。
对于 development ENV 中的实例,我可以 运行 rake db:migrate:status
它告诉我哪些迁移是 up
或 down
和 will/need 到 运行.
我的deploy.rb
namespace/function
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
end
end
desc "reload the database with seed data"
task :seed do
puts "\n=== Seeding Database ===\n"
on primary :db do
within current_path do
with rails_env: fetch(:stage) do
execute :rake, 'db:seed'
end
end
end
end
end
我的其他 deploy.rb
有所有常见的东西,例如:
set :application
、set :repo_url
、set :passenger_restart_with_touch
、set :deploy_to
、set :bundle_binstubs
、set :linked_files
、set :linked_dirs
我的版本:
Rails: 4.2.4
Capistrano: 3.5
您有两种初始化 Capistrano 的方法-Rails Gem。在您的 Capfile
中,您可以添加 require 'capistrano/rails'
,这将生成资产和 运行 迁移,或者您可以添加 require 'capistrano/rails/assets'
and/or require 'capistrano/rails/migrations'
,这将做一个或另一个,或两者都包括在内。
因此,为了避免 运行 迁移,请确保 require 'capistrano/rails'
和 require 'capistrano/rails/migrations'
不在您的 Capfile 中。