开发模式与生产模式不匹配。耙子流产了

时间:2011-09-12 15:16:25

标签: ruby-on-rails

我正处于应用程序的部署阶段并发现了一些错误......我正在使用Capistrano和Mongrel,而deploy.rb文件就是这样的

set :application, "ngs_app"
set :repository,  "file:///Users/Admin/svnrepo/#{application}"
set :deploy_to,   "/Library/WebServer/#{application}"
set :deploy_via,  :export
set :scm_username, "Admin"
set :scm_password, "##########"
set :scm, :subversion
ssh_options[:forward_agent] = true

# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

role :web, "130.209.53.216"                          # Your HTTP server, Apache/etc
role :app, "130.209.53.216"                          # This may be the same as your `Web` server
role :db,  "130.209.53.216", :primary => true        # This is where Rails migrations will run
# role :db,  "your slave db-server here"
# Adding Mongrel_specific variables
set :mongrel_cmd, "/usr/bin/mongrel_rails_persist"
set :mongrel_ports, 3000..3003
set :user, "Admin"
set :group, "administrator"

# Adding Capistrano tasks 
namespace :deploy do
desc "Start Mongrel processes and add them to launchd. "
task :start, :roles => :app do 
  mongrel_ports.each do |port|
    sudo "#{mongrel_cmd} start -p #{port} -e production --user #{user} --group #{group} -c #{current_path}"
  end
end
desc "Stop mongrels processess and remove them from launchd. "
task :stop, :roles => :app do 
  mongrel_ports.each do |port|
    sudo "#{mongrel_cmd} stop -p #{port}"
  end
end
desc "Restart Mongrel processes"
task :restart, :roles => :app do 
  stop 
  start
end
end

The error message I get are the following

sudo cap deploy:cold
  * executing `deploy:cold'
  * executing `deploy:update'
** transaction: start
  * executing `deploy:update_code'
    executing locally: "svn info file:///Users/Admin/svnrepo/ngs_app --username Admin --password colonsay2010 --no-auth-cache  -rHEAD"
    command finished in 9ms
  * executing "svn export -q --username Admin --password colonsay2010 --no-auth-cache  -r2 file:///Users/Admin/svnrepo/ngs_app /Library/WebServer/ngs_app/releases/20110912144920 && (echo 2 > /Library/WebServer/ngs_app/releases/20110912144920/REVISION)"
    servers: ["130.209.53.216"]
Password: 
    [130.209.53.216] executing command
    command finished in 704ms
  * executing `deploy:finalize_update'
  * executing "chmod -R g+w /Library/WebServer/ngs_app/releases/20110912144920"
    servers: ["130.209.53.216"]
    [130.209.53.216] executing command
    command finished in 31ms
  * executing "rm -rf /Library/WebServer/ngs_app/releases/20110912144920/log /Library/WebServer/ngs_app/releases/20110912144920/public/system /Library/WebServer/ngs_app/releases/20110912144920/tmp/pids &&\\\n      mkdir -p /Library/WebServer/ngs_app/releases/20110912144920/public &&\\\n      mkdir -p /Library/WebServer/ngs_app/releases/20110912144920/tmp &&\\\n      ln -s /Library/WebServer/ngs_app/shared/log /Library/WebServer/ngs_app/releases/20110912144920/log &&\\\n      ln -s /Library/WebServer/ngs_app/shared/system /Library/WebServer/ngs_app/releases/20110912144920/public/system &&\\\n      ln -s /Library/WebServer/ngs_app/shared/pids /Library/WebServer/ngs_app/releases/20110912144920/tmp/pids"
    servers: ["130.209.53.216"]
    [130.209.53.216] executing command
    command finished in 21ms
  * executing "find /Library/WebServer/ngs_app/releases/20110912144920/public/images /Library/WebServer/ngs_app/releases/20110912144920/public/stylesheets /Library/WebServer/ngs_app/releases/20110912144920/public/javascripts -exec touch -t 201109121449.25 {} ';'; true"
    servers: ["130.209.53.216"]
    [130.209.53.216] executing command
    command finished in 100ms
  * executing `deploy:symlink'
  * executing "rm -f /Library/WebServer/ngs_app/current && ln -s /Library/WebServer/ngs_app/releases/20110912144920 /Library/WebServer/ngs_app/current"
    servers: ["130.209.53.216"]
    [130.209.53.216] executing command
    command finished in 10ms
** transaction: commit
  * executing `deploy:migrate'
  * executing "cd /Library/WebServer/ngs_app/releases/20110912144920 && rake RAILS_ENV=production  db:migrate"
    servers: ["130.209.53.216"]
    [130.209.53.216] executing command
*** [err :: 130.209.53.216] rake aborted!
*** [err :: 130.209.53.216] 
*** [err :: 130.209.53.216] An error has occurred, this and all later migrations canceled:
*** [err :: 130.209.53.216] 
*** [err :: 130.209.53.216] SQLite3::SQLException: duplicate column name: organism: ALTER TABLE "samples" ADD "organism" varchar(255)
*** [err :: 130.209.53.216] 
*** [err :: 130.209.53.216] 
*** [err :: 130.209.53.216] (See full trace by running task with --trace)
*** [err :: 130.209.53.216] 
** [out :: 130.209.53.216] (in /Library/WebServer/ngs_app/releases/20110912144920)
** [out :: 130.209.53.216] ==  CreateBatches: migrating ==================================================
** [out :: 130.209.53.216] -- create_table(:batches)
** [out :: 130.209.53.216] -> 0.0012s
** [out :: 130.209.53.216] ==  CreateBatches: migrated (0.0013s) =========================================
** [out :: 130.209.53.216] 
** [out :: 130.209.53.216] ==  CreateSamples: migrating ==================================================
** [out :: 130.209.53.216] -- create_table(:samples)
** [out :: 130.209.53.216] -> 0.0020s
** [out :: 130.209.53.216] ==  CreateSamples: migrated (0.0021s) =========================================
** [out :: 130.209.53.216] 
** [out :: 130.209.53.216] ==  AddMajorToBatch: migrating ================================================
** [out :: 130.209.53.216] -- add_column(:batches, :submit_date, :date)
** [out :: 130.209.53.216] -> 0.0007s
** [out :: 130.209.53.216] -- add_column(:batches, :grp_leader, :string)
** [out :: 130.209.53.216] -> 0.0004s
** [out :: 130.209.53.216] -- add_column(:batches, :contact_person, :string)
** [out :: 130.209.53.216] -> 0.0003s
** [out :: 130.209.53.216] -- add_column(:batches, :batch_comment, :text)
** [out :: 130.209.53.216] -> 0.0003s
** [out :: 130.209.53.216] ==  AddMajorToBatch: migrated (0.0019s) =======================================
** [out :: 130.209.53.216] 
** [out :: 130.209.53.216] ==  AddSecondToBatch: migrating ===============================================
** [out :: 130.209.53.216] -- add_column(:batches, :sample_type, :string)
** [out :: 130.209.53.216] -> 0.0007s
** [out :: 130.209.53.216] -- add_column(:batches, :extraction, :string)
** [out :: 130.209.53.216] -> 0.0004s
** [out :: 130.209.53.216] -- add_column(:batches, :cleanup, :string)
** [out :: 130.209.53.216] -> 0.0004s
** [out :: 130.209.53.216] -- add_column(:batches, :suspension, :string)
** [out :: 130.209.53.216] -> 0.0003s
** [out :: 130.209.53.216] ==  AddSecondToBatch: migrated (0.0020s) ======================================
** [out :: 130.209.53.216] 
** [out :: 130.209.53.216] ==  AddThirdToBatch: migrating ================================================
** [out :: 130.209.53.216] -- add_column(:batches, :preparation, :string)
** [out :: 130.209.53.216] -> 0.0013s
** [out :: 130.209.53.216] -- add_column(:batches, :sequencing, :string)
** [out :: 130.209.53.216] -> 0.0004s
** [out :: 130.209.53.216] ==  AddThirdToBatch: migrated (0.0019s) =======================================
** [out :: 130.209.53.216] 
** [out :: 130.209.53.216] ==  AddThingsToSample: migrating ==============================================
** [out :: 130.209.53.216] -- add_column(:samples, :organism, :string)
    command finished in 1722ms
failed: "sh -c 'cd /Library/WebServer/ngs_app/releases/20110912144920 && rake RAILS_ENV=production  db:migrate'" on 130.209.53.216

有人可以帮我解决耙子流产的问题吗? 提前谢谢

1 个答案:

答案 0 :(得分:0)

有些可能性如下:

  • 有人修改了现有的db_migration_XXX.rb脚本。从生产数据库的角度来看,此脚本已经运行
  • 数据库迁移脚本中有多个预期的操作,如果脚本在运行时第一次中止并且您尝试重新运行脚本,则通常会发生此类问题。