Skip to content

Instantly share code, notes, and snippets.

@zegomesjf
Created July 25, 2014 12:31
Show Gist options
  • Save zegomesjf/a4ebc5b288e15097a683 to your computer and use it in GitHub Desktop.
Save zegomesjf/a4ebc5b288e15097a683 to your computer and use it in GitHub Desktop.
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