Sha256: 412512d88cefc5197be475d63d11017f9e50bf92f31272c4fb8a445d85e43b83
Contents?: true
Size: 1.55 KB
Versions: 8
Compression:
Stored size: 1.55 KB
Contents
module RussellEdge class DataMigrator class << self def prepare_upgrade_migrations dirs = Rails::Application::Railties.engines.map{|p| p.config.root.to_s} dirs.each do |dir| if File.directory? File.join(dir,'db/data_migrations/upgrade') target = File.join(dir,'db/data_migrations/') files = Dir["#{target}*.rb"] unless files.empty? FileUtils.mkdir_p "#{target}app/" FileUtils.cp files, "#{target}app/" puts "copied #{files.size} upgrade data migrations to #{target}app" end files = Dir["#{File.join(dir,'db/data_migrations/upgrade')}/*.rb"] FileUtils.cp files, File.join(dir,'db/data_migrations/') end end end def cleanup_upgrade_migrations dirs = Rails::Application::Railties.engines.map{|p| p.config.root.to_s} dirs.each do |dir| if File.directory? File.join(dir,'db/data_migrations/app') target = File.join(dir,'db/data_migrations/') files = Dir["#{target}/*.rb"] unless files.empty? FileUtils.rm files puts "removed #{files.size} data migrations from #{target}" end files = Dir["#{target}/app/*.rb"] unless files.empty? FileUtils.cp files, target puts "copied #{files.size} data migrations back to #{target}" end FileUtils.rm_rf "#{target}/app" end end end end end#DataMigrator end#RussellEdge
Version data entries
8 entries across 8 versions & 1 rubygems