Created
July 25, 2014 12:31
-
-
Save zegomesjf/a4ebc5b288e15097a683 to your computer and use it in GitHub Desktop.
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 :db do | |
desc "Migrate the database (options: VERSION=x, VERBOSE=false)." | |
task migrate: :environment do | |
puts "ANTES DE TUDO" | |
verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true | |
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil | |
migrations_paths = ActiveRecord::Migrator.migrations_paths | |
puts "antes do verbose" | |
ActiveRecord::Migration.verbose = verbose | |
ActiveRecord::Migrator.migrate(migrations_paths, version) | |
puts "antes do if safado" | |
if Rails.env != 'development' && Rails.env != 'test' | |
puts "depois do if safado" | |
Customer.find_each do |customer| | |
puts "migrating customer #{customer.domain}" | |
customer.using_connection do | |
ActiveRecord::Migrator.migrate(migrations_paths, version) | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment