Sha256: 5b564d231460db659f05f72efd3b0c2aeb919a9fe684aa1e3e173e1ad16e72b9

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

module Reflection
  module Rails
    
    autoload :Database, 'reflection/rails/database'
    
    class << self
      
      def validate_environment(config)
        env_file_path = File.join(config.rails_root, 'config/environments', "#{config.rails_environment}.rb")
        unless File.exist?(env_file_path)
          Reflection::Support.exit_with_error("Rails environment '#{config.rails_environment}' doesn't exist in #{env_file_path}.")
        end
      end
      
      # TODO: 
      # Method is obsolete and has moved to Rails::Database
      # Cannot be removed atm because Command::Stash depends on it
      def clean_target(config, target_directory)
        database = Database.new(config.rails_root, config.rails_environment)
        database.clean_dump_file(target_directory.path)
      end
      
      def stash(config, target_directory)
        Reflection.log.debug "Stashing database dump.."
        database = Database.new(config.rails_root, config.rails_environment)
        database.dump_to_directory(target_directory.path)
      end
    
      def apply(config, target_directory)
        Reflection.log.debug "Applying database dump.."        
        database = Database.new(config.rails_root, config.rails_environment)
        database.recreate!
        database.load_dump_from_file(target_directory.path)
        database.clean_dump_file(target_directory.path)
        database.migrate!
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
basiszwo-reflection-0.5.1 lib/reflection/rails.rb
reflection-0.5.0 lib/reflection/rails.rb