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

Version Path
erp_base_erp_svcs-3.0.7 lib/erp_base_erp_svcs/extensions/active_record/data_migrator.rb
erp_base_erp_svcs-3.0.6 lib/erp_base_erp_svcs/extensions/active_record/data_migrator.rb
erp_base_erp_svcs-3.0.5 lib/erp_base_erp_svcs/extensions/active_record/data_migrator.rb
erp_base_erp_svcs-3.0.4 lib/erp_base_erp_svcs/extensions/active_record/data_migrator.rb
erp_base_erp_svcs-3.0.3 lib/erp_base_erp_svcs/extensions/active_record/data_migrator.rb
erp_base_erp_svcs-3.0.2 lib/erp_base_erp_svcs/extensions/active_record/data_migrator.rb
erp_base_erp_svcs-3.0.1 lib/erp_base_erp_svcs/extensions/active_record/data_migrator.rb
erp_base_erp_svcs-3.0.0 lib/erp_base_erp_svcs/extensions/active_record/data_migrator.rb