Permalink
Browse files

Adding migration task

  • Loading branch information...
1 parent 383f0a1 commit 04103952ba82af0231036a9c8a29332d77820385 Emil Kampp committed Feb 23, 2012
Showing with 23 additions and 11 deletions.
  1. +1 −1 README.md
  2. +1 −1 capistrano-rake-recipes.gemspec
  3. +1 −9 lib/capistrano-rake-recipes.rb
  4. +20 −0 lib/capistrano-rake-recipes/recipes.rb
View
@@ -6,7 +6,7 @@ In essence this set of recipes simply allow you to run command from your local b
To use it simply run this command, to execute a `db:migrate`:
- bundle exec cap rake db:migrate --db
+ bundle exec cap rake migrate --db
As one would expect this will run the command on the primary database server.
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.version = Capistrano::Rake::Recipes::VERSION
s.authors = ["Emil Kampp"]
s.email = ["emil@kampp.me"]
- s.homepage = "emil.kampp.me"
+ s.homepage = "http://emil.kampp.me"
s.summary = %q{This allows to run rake tasks on the remote servers}
s.description = %q{This allows to run rake tasks on the remote servers}
@@ -1,9 +1 @@
-require "capistrano-rake-recipes/version"
-
-module Capistrano
- module Rake
- module Recipes
- # Your code goes here...
- end
- end
-end
+require "capistrano-rake-recipes/version"
@@ -0,0 +1,20 @@
+Capistrano::Configuration.instance.load do
+ set(:rake_group) { :db }
+
+ namespace :rake do
+ desc "Migrates the database"
+ task :migrate, :roles => :db, :primary => true do
+ cmd = (command || "db:migrate") + " RAILS_ENV=#{rails_env}"
+ logger.info "Running #{cmd}"
+ run "cd #{current_path}; bundle exec rake #{cmd}"
+ end
+
+ # This compiles the requested command
+ task :command do
+ cut = ARGV.index("-s")
+ cmd = nil
+ cmd = ARGV[(cut+1)..-1].join(" ") unless cut.nil?
+ cmd
+ end
+ end
+end

0 comments on commit 0410395

Please sign in to comment.