Advertisement
Guest User

Untitled

a guest
May 14th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. task :migrate_accounts_schema => [:environment] do |t|
  2. users = User.find :all, :conditions => ["state = 2"], :order => "id asc"
  3. users.each do |user|
  4. if user.state == 2
  5. ActiveRecord::Base.establish_connection(
  6. :adapter => "postgresql",
  7. :host => user.database_host,
  8. :port => user.database_port,
  9. :username => user.subdomain,
  10. :password => "#{user.database_password}",
  11. :database => user.database_name
  12. )
  13. Rake::Task["db:migrate"].invoke
  14. end
  15. end
  16. end
  17.  
  18. ** Invoke app:migrate_accounts_schema (first_time)
  19. ** Invoke environment (first_time)
  20. ** Execute environment
  21. ** Execute app:migrate_accounts_schema
  22. ** Invoke db:migrate (first_time)
  23. ** Invoke environment
  24. ** Execute db:migrate
  25. ** Invoke db:schema:dump (first_time)
  26. ** Invoke environment
  27. ** Execute db:schema:dump
  28. ** Invoke db:migrate
  29.  
  30. # db/seed.rb
  31. Rake::Task['catalog:destroy'].invoke
  32.  
  33. files = Dir.glob("private/catalog/*").sort
  34. files.each do |file|
  35. next unless File.extname(file) == '.xlsx'
  36. puts file.split('/').last
  37. Rake::Task['catalog:upload'].invoke(file)
  38. Rake::Task['catalog:upload'].reenable
  39. puts
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement