Class: RequestMigrations::Migrator
- Inherits:
-
Object
- Object
- RequestMigrations::Migrator
- Defined in:
- lib/request_migrations/migrator.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(from:, to:) ⇒ Migrator
constructor
Migrator represents a versioned migration from one version to another.
-
#migrate!(data:) ⇒ void
migrate! attempts to apply all matching migrations on data.
Constructor Details
#initialize(from:, to:) ⇒ Migrator
Migrator represents a versioned migration from one version to another.
10 11 12 13 |
# File 'lib/request_migrations/migrator.rb', line 10 def initialize(from:, to:) @current_version = Version.new(from) @target_version = Version.new(to) end |
Instance Method Details
#migrate!(data:) ⇒ void
This method returns an undefined value.
migrate! attempts to apply all matching migrations on data.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/request_migrations/migrator.rb', line 21 def migrate!(data:) logger.debug { "Migrating from #{current_version} to #{target_version} (#{migrations.size} potential migrations)" } migrations.each_with_index { |migration, i| logger.debug { "Applying migration #{migration} (#{i + 1}/#{migrations.size})" } migration.new.migrate!(data) } logger.debug { "Migrated from #{current_version} to #{target_version}" } end |