Sha256: 3f7ecafee927be9bfb88f1763640df0b849e99805cb6d8bd1053e99eabc6cdb9

Contents?: true

Size: 751 Bytes

Versions: 16

Compression:

Stored size: 751 Bytes

Contents

begin
  require "dynomite"
rescue LoadError # Commands::Base.eager_load
  nil
end

class Jets::Commands::Dynamodb::Migrator
  def initialize(path, options)
    @path = path
    @options = options
  end

  def run
    puts "Running database migrations"
    return if @options[:noop]
    migrate
  end

  def migrate
    path = "#{Jets.root}#{@path}"
    unless File.exist?(path)
      puts "Unable to find the migration file: #{path}"
      exit 1 unless ENV['TEST']
    end

    require path
    migration_class = get_migration_class
    migration_class.new.up
  end

  def get_migration_class
    filename = File.basename(@path, '.rb')
    filename = filename.sub(/\d+[-_]/, '') # strip leading timestsamp
    filename.classify.constantize
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
jets-1.6.1 lib/jets/commands/dynamodb/migrator.rb
jets-1.6.0 lib/jets/commands/dynamodb/migrator.rb
jets-1.5.10 lib/jets/commands/dynamodb/migrator.rb
jets-1.5.9 lib/jets/commands/dynamodb/migrator.rb
jets-1.5.8 lib/jets/commands/dynamodb/migrator.rb
jets-1.5.7 lib/jets/commands/dynamodb/migrator.rb
jets-1.5.6 lib/jets/commands/dynamodb/migrator.rb
jets-1.5.5 lib/jets/commands/dynamodb/migrator.rb
jets-1.5.4 lib/jets/commands/dynamodb/migrator.rb
jets-1.5.3 lib/jets/commands/dynamodb/migrator.rb
jets-1.5.2 lib/jets/commands/dynamodb/migrator.rb
jets-1.5.1 lib/jets/commands/dynamodb/migrator.rb
jets-1.5.0 lib/jets/commands/dynamodb/migrator.rb
jets-1.4.11 lib/jets/commands/dynamodb/migrator.rb
jets-1.4.10 lib/jets/commands/dynamodb/migrator.rb
jets-1.4.9 lib/jets/commands/dynamodb/migrator.rb