【问题标题】:Rake db:Migrate with Nginx CapistranoRake db:使用 Nginx Capistrano 迁移
【发布时间】:2015-07-30 20:10:45
【问题描述】:

我正在使用 Nginx、Capistrano、Rails 运行服务器

我在本地机器上做了一些 db:migrations,然后想将它们推送到我的服务器上。但是我不知道如何在服务器上迁移我的数据库。我该怎么做?

我试过了

1)

cap production deploy
cap production deploy:migrate

2)

[On server - in current]
rake db:migrate

但这些似乎都不起作用。如何进行此迁移?

Capistrano 文件

lock '3.4.0'
 require 'capistrano/sidekiq'
 set :whenever_command, "bundle exec whenever"
 require "whenever/capistrano"
set :application, 'myApp'
set :repo_url, 'git...'
set :keep_releases, 5
set :scm, :git
set :repository, "git..."
set :scm_passphrase, "..."
set :user, "..."
set :use_sudo, false
set :deploy_to, "/.../.../apps/appName"
namespace :deploy do
  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
    end
  end
end

【问题讨论】:

    标签: ruby-on-rails nginx capistrano


    【解决方案1】:

    1) 如果你使用 capistrano-rails 你应该设置

    set :migration_role, 'migrator'            # Defaults to 'db'
    

    2) 在您正在开发环境中进行迁移的服务器上,尝试

    RAILS_ENV=production bundle exec rails db:migrate

    【讨论】:

      【解决方案2】:

      要使用 capistrano 运行迁移,请在 production.rb 位于 /config/deploy 内的文件上添加“db”角色 例如

      roles: %w{web app db}

      如果current_pathrelease_path 迁移之间存在差异,capistrano 迁移任务也可以工作。您可以做的是从 current_path 内部删除迁移,然后部署,然后迁移。

      【讨论】:

        猜你喜欢
        • 2013-02-01
        • 2012-11-17
        • 1970-01-01
        • 1970-01-01
        • 2012-02-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多