Class: Jets::Commands::Dynamodb::Migrator
- Inherits:
-
Object
- Object
- Jets::Commands::Dynamodb::Migrator
- Defined in:
- lib/jets/commands/dynamodb/migrator.rb
Instance Method Summary collapse
- #get_migration_class ⇒ Object
-
#initialize(path, options) ⇒ Migrator
constructor
A new instance of Migrator.
- #migrate ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(path, options) ⇒ Migrator
Returns a new instance of Migrator.
8 9 10 11 |
# File 'lib/jets/commands/dynamodb/migrator.rb', line 8 def initialize(path, ) @path = path @options = end |
Instance Method Details
#get_migration_class ⇒ Object
31 32 33 34 35 |
# File 'lib/jets/commands/dynamodb/migrator.rb', line 31 def get_migration_class filename = File.basename(@path, '.rb') filename = filename.sub(/\d+[-_]/, '') # strip leading timestsamp filename.camelize.constantize end |
#migrate ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jets/commands/dynamodb/migrator.rb', line 19 def migrate path = "#{Jets.root}/#{@path}" unless File.exist?(path) puts "Unable to find the migration file: #{path}" exit 1 unless Jets.env.test? end require path migration_class = get_migration_class migration_class.new.up end |
#run ⇒ Object
13 14 15 16 17 |
# File 'lib/jets/commands/dynamodb/migrator.rb', line 13 def run puts "Running database migrations" return if @options[:noop] migrate end |