Created
November 23, 2011 03:09
-
-
Save gonzedge/1387792 to your computer and use it in GitHub Desktop.
Stripping down Rails 3.1: Using only the database migrations
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
tasks = [:create, :drop, :migrate, :rollback, :version, :seed, :setup] | |
tasks.each do |name| | |
task name do | |
sh "rake db:#{name.to_s} RAILS_ENV={environment}" | |
end | |
end |
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
source 'http://rubygems.org' | |
gem 'git-deploy' | |
gemfile = File.open(File.join(File.dirname(__FILE__), 'deploy', 'Gemfile')) | |
eval gemfile.read |
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
rails new deploy |
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
rakefile = File.open(File.join(File.dirname(__FILE__), 'deploy', 'Rakefile')) | |
eval rakefile.read.gsub(/config/, 'deploy/config') | |
task :generate do | |
arguments = ARGV.find { |a| a.start_with?('GENERATE=') } | |
arguments = arguments.split('=')[1] unless arguments.nil? | |
sh "cd deploy; rails generate #{arguments}" unless arguments.nil? or arguments.empty? | |
end | |
db_tasks_file = File.open(File.join(File.dirname(__FILE__), 'deploy', 'lib', 'tasks', 'db.rb')) | |
db_tasks = db_tasks_file.read | |
namespace :db do | |
namespaces = [:test, :production] | |
namespaces.each do |name| | |
namespace name do | |
eval db_tasks.gsub(/{environment}/, name.to_s) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment