Sha256: e8e3e75dc512c8c0db0a0be65dc35681b350fd7ada3809ab01e2e2ab62e572a0

Contents?: true

Size: 794 Bytes

Versions: 1

Compression:

Stored size: 794 Bytes

Contents

module Databasion
  
  class Migrate
    
    @@config = nil
    
    def self.config=(config)
      @@config = config
    end
    
    def self.run
      require 'migration_helpers/init'

      files = Dir["%s/*.yml" % @@config['output']['yaml_path']]
      Databasion::BuildMigration.run(files, @@config)

      Databasion.set_ar_logger
      Databasion::LOGGER.info "Migrating..."

      YAML.load_file('config/database.yml').each do |config|
        ActiveRecord::Base.establish_connection(config[1])
        path = @@config['output']['migrations']['path'] + "/" + config[0]
        ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
        ActiveRecord::Migrator.migrate(path, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
      end
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
databasion-0.1.1 lib/databasion/migrate.rb