2012-06-08 87 views
0

这是我的第一个铁轨项目,它与Capistrano合作非常愉快。capistrano部署:迁移不存在

我目前的问题是我需要运行cap deploy:migrate和cap:deploy:migration作为单独的任务。我相信应该有一个帽子部署:迁移结合这些。

这里是我的终端输出:

kris$ cap staging deploy:migration 
     triggering load callbacks 
    * executing `staging' 
    the task `deploy:migration' does not exist 

我的设置是采用多阶段和使用RVM Capistrano的插件。

这里是我的宝石文件:

source 'https://rubygems.org' 

gem 'rails', '3.2.1' 

group :development do 
    gem 'sqlite3' 
end 

group :production do 
    gem 'mysql2' 
end 

group :test do 
    gem 'sqlite3' 
    gem 'ZenTest' 
end 

# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', '~> 3.2.3' 
    gem 'coffee-rails', '~> 3.2.1' 
    gem 'uglifier', '>= 1.0.3' 
end 

#formtastic 2.2 breaks activeadmin 
gem "formtastic", "~> 2.1.1" 
gem "activeadmin", "~> 0.4.3" 

# meta_search required for activeadmin 
gem 'meta_search' 

gem 'jquery-rails' 
gem "paperclip", "~> 3.0" 

gem 'acts_as_list' 
gem 'unicorn' 

# Deploy with Capistrano 
gem 'capistrano' 
gem 'rvm-capistrano' 

gem 'mail' 
gem 'friendly_id' 

,这里是我的配置/部署文件:

set :rvm_ruby_string, '[email protected]'      # Or: 
#set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"") # Read from local system 

require "rvm/capistrano"        # Load RVM's capistrano plugin. 
require "bundler/capistrano" 

# set :verbose ,1 

require 'capistrano/ext/multistage' 
set :stages, %w(staging production) 
set :default_stage, "staging" 
set :deploy_via, :remote_cache 

set :user, "webm" 
# set :deploy_via, :remote_cache 
set :use_sudo, false 

set :scm, "git" 
set :repository, "[email protected]:/xx.git" 

# :branch is being set in stage files 

default_run_options[:pty] = true 
# ssh_options[:forward_agent] = true 

after "deploy", "deploy:cleanup" # keep only the last 5 releases 

namespace :deploy do 
    %w[start stop restart].each do |command| 
     desc "#{command} unicorn server" 
     task command, roles: :app, except: {no_release: true} do 
      run "#{sudo} service unicorn_#{server_configuration} #{command}" 
     end 
    end 

    desc "build missing paperclip styles" 
    task :build_missing_paperclip_styles, :roles=> :app do 
     run "cd #{release_path}; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles" 
    end 
    after "deploy:update", "deploy:build_missing_paperclip_styles" 

    task :setup_config, roles: :app do 
     puts "#making symlink to nginx sites-enabled" 
     run "#{sudo} ln -fs #{current_path}/config/server/#{server_configuration}/nginx.conf /etc/nginx/sites-enabled/#{server_configuration}" 
     puts "#making symlink to unicorn service script" 
     run "#{sudo} ln -fs #{current_path}/config/server/#{server_configuration}/unicorn_init.sh /etc/init.d/unicorn_#{server_configuration}" 
     puts "#making a the new config directory" 
     run "mkdir -p #{shared_path}/config" 
     run "sunique 1" 
     put File.read("config/database.yml"), "#{shared_path}/config/database.yml" 
     run "sunique 0" 
     puts "Now edit the config files in #{shared_path}." 
    end 
    after "deploy:setup", "deploy:setup_config" 

    task :symlink_config, roles: :app do 
     run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" 

     puts "#for reference:" 
     puts "#rvm wrapper [email protected]_helenefrance_01 [email protected]#{server_configuration} unicorn cap" 
     puts "#now be sure to run: sudo update-rc.d unicorn_#{server_configuration} defaults" 
    end 
    after "deploy:finalize_update", "deploy:symlink_config" 

    # desc "Make sure local git is in sync with remote." 
    # task :check_revision, roles: :web do 
     # if :isRemote == false 
      # unless `git rev-parse HEAD` == `git rev-parse beanstalk/#{branch}` 
       # puts "WARNING: HEAD is not the same as beanstalk/#{branch}" 
       # puts "Run `git push` to sync changes." 
       # exit 
      # end 
     # end 
    # end 
    #before "deploy", "deploy:check_revision" 
end 

与为什么deploy:migration被打破将是非常有益的帮助。 谢谢。

+1

结帐帽-T查看可用帽任务 –

+0

这是一个很好的提示。谢谢。 – LessQuesar

回答

4

你忘了小号,如cap deploy:migrations

+0

错字!?!你是对的,非常感谢。 – LessQuesar