Created
January 23, 2013 17:14
-
-
Save freegenie/4610250 to your computer and use it in GitHub Desktop.
Snipped of code to finally have capistrano run db:schema:load on cold deploys. Paste this in your capistrano recipe.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :deploy do | |
task :load_schema, :roles => :db, :only => { :primary => true } do | |
rake = fetch(:rake, "rake") | |
rails_env = fetch(:rails_env, "production") | |
migrate_env = fetch(:migrate_env, "") | |
migrate_target = fetch(:migrate_target, :latest) | |
directory = case migrate_target.to_sym | |
when :current then current_path | |
when :latest then latest_release | |
else raise ArgumentError, "unknown migration target #{migrate_target.inspect}" | |
end | |
run "cd #{directory} && #{rake} RAILS_ENV=#{rails_env} #{migrate_env} db:schema:load" | |
end | |
task :cold do | |
update_code | |
load_schema | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment