Class: LazyMigrate::OldMigratorAdapter

Inherits:
MigratorAdapter show all
Extended by:
T::Sig
Defined in:
lib/lazy_migrate/old_migrator_adapter.rb

Instance Method Summary collapse

Methods inherited from MigratorAdapter

#bring_to_top, #dump_schema, #find_migrations, #initialize, #load_migration_paths, #previous_value, #remove_version_from_table, #replace_version_in_filename

Constructor Details

This class inherits a constructor from LazyMigrate::MigratorAdapter

Instance Method Details

#down(version) ⇒ Object



25
26
27
# File 'lib/lazy_migrate/old_migrator_adapter.rb', line 25

def down(version)
  ActiveRecord::Migrator::Compatibility::V5_1.run(:down, ActiveRecord::Tasks::DatabaseTasks.migrations_paths, version)
end

#migrate(version) ⇒ Object



36
37
38
# File 'lib/lazy_migrate/old_migrator_adapter.rb', line 36

def migrate(version)
  ActiveRecord::Migrator::Compatibility::V5_1.migrate(base_paths, version)
end

#redo(version) ⇒ Object



30
31
32
33
# File 'lib/lazy_migrate/old_migrator_adapter.rb', line 30

def redo(version)
  down(version)
  up(version)
end

#rollback(version) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/lazy_migrate/old_migrator_adapter.rb', line 41

def rollback(version)
  previous_version = find_previous_version(version)

  if previous_version.nil?
    # rails excludes the given version when calling .migrate so we need to
    # just down this instead
    down(version)
  else
    ActiveRecord::Migrator::Compatibility::V5_1.migrate(base_paths, previous_version)
  end
end

#up(version) ⇒ Object



20
21
22
# File 'lib/lazy_migrate/old_migrator_adapter.rb', line 20

def up(version)
  ActiveRecord::Migrator::Compatibility::V5_1.run(:up, ActiveRecord::Tasks::DatabaseTasks.migrations_paths, version)
end