Skip to content

Instantly share code, notes, and snippets.

@darrenboyd
Created July 23, 2009 15:25
Show Gist options
  • Save darrenboyd/153080 to your computer and use it in GitHub Desktop.
Save darrenboyd/153080 to your computer and use it in GitHub Desktop.
namespace :deploy do
namespace :gate do
task :default do
if "#{stage}" == "production"
stg = CLI.ui.ask "Which environment are you deploying to again? "
unless stg == "#{stage}"
puts "I am not convinced, sorry."
exit(1)
end
end
end
task :schema do
migrations = `git diff --name-only #{current_revision}..#{branch} db/migrate`
if migrations.length > 0
question = "It looks like there are pending migrations in this changeset:\n"
question << migrations + "\n"
question << "Are you sure you want to deploy without migrations (y/n)?"
answer = CLI.ui.ask(question)
unless answer =~ /^y(es)?/i
puts "Deploy aborted."
exit(-1)
end
end
end
end
before "deploy", "deploy:gate"
before 'deploy', 'deploy:gate:schema'
before "deploy:migrations", "deploy:gate"
# ... rest of deploy.rb file
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment