Class: DataMigrater::Migrator
- Inherits:
-
Object
- Object
- DataMigrater::Migrator
- Defined in:
- lib/data_migrater/migrator.rb
Instance Method Summary collapse
-
#initialize(collection = DataMigrater::Collection.new) ⇒ Migrator
constructor
A new instance of Migrator.
- #migrate ⇒ Object
Constructor Details
#initialize(collection = DataMigrater::Collection.new) ⇒ Migrator
Returns a new instance of Migrator.
5 6 7 |
# File 'lib/data_migrater/migrator.rb', line 5 def initialize(collection = DataMigrater::Collection.new) @collection = collection end |
Instance Method Details
#migrate ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/data_migrater/migrator.rb', line 9 def migrate return unless DataMigration.table_exists? begin ActiveRecord::Migration.check_pending! ActiveRecord::Base.transaction do @collection.migrations.each(&:execute) end rescue ActiveRecord::PendingMigrationError puts 'DataMigrater stopped. Pending migrations need to executed!' end end |