修改Capfile,在正式环境不再使用migration修改数据库



原因是这样的,运维不开放正式环境数据库的alter权限,所以每次都要给他们把sql语句发过去,

由他们来操作。

https://github.com/capistrano/rails

Require everything (bundler, rails/assets and rails/migrations):

# Capfile
require 'capistrano/rails'
Or require just what you need manually:

# Capfile
require 'capistrano/bundler' # Rails needs Bundler, right?
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

参考的是https://github.com/capistrano/rvm/issues/49

Using the task pattern described before, capistrano/rvm gets required after capistrano/bundler. This makes capistrano use the command bundle exec ruby --version. This command would fail on the server when it is run inside a directory without a Gemfile.

There are two ways to make this work:

1) Avoid using bundle exec for all ruby commands:

Capfile

task :require_rvm do
  require 'capistrano/rvm'
end
task 'staging' => [:require_rvm]

require 'capistrano/bundler'
config/deploy/staging.rb

set :bundle_bins, %w(gem rake rails)
2) Require bundler the same way we require rvm:

Capfile

task :require_rvm do
  require 'capistrano/rvm'end

task :require_bundler do
  require 'capistrano/bundler'
end

task 'staging' => [:require_rvm, :require_bundler]
task 'production' => [:require_bundler]



以下是最终修改后的Capfile

task :require_rails do
  require 'capistrano/rails'
end
# require 'capistrano/rvm'
require 'capistrano/rbenv'
# require 'capistrano/chruby'
task :require_rails_without_migrations do
  require 'capistrano/bundler'
  require 'capistrano/rails/assets'
end
# require 'capistrano/rails/migrations'
# require 'capistrano/passenger'

task :staging => [:require_rails]
task :production => [:require_rails_without_migrations]


你可能感兴趣的:(修改Capfile,在正式环境不再使用migration修改数据库)