Class: LazyMigrate::NewMigratorAdapter
Instance Attribute Summary collapse
Instance Method Summary
collapse
#bring_to_top, #dump_schema, #find_migrations, #load_migration_paths, #previous_value, #remove_version_from_table, #replace_version_in_filename
Constructor Details
Returns a new instance of NewMigratorAdapter.
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/lazy_migrate/new_migrator_adapter.rb', line 15
def initialize
@context = T.let(
ActiveRecord::MigrationContext.instance_method(:initialize).arity == 2 ?
ActiveRecord::MigrationContext.new(Rails.root.join('db', 'migrate'), ActiveRecord::SchemaMigration) :
ActiveRecord::MigrationContext.new(Rails.root.join('db', 'migrate')),
ActiveRecord::MigrationContext,
)
end
|
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
12
13
14
|
# File 'lib/lazy_migrate/new_migrator_adapter.rb', line 12
def context
@context
end
|
Instance Method Details
#down(version) ⇒ Object
32
33
34
|
# File 'lib/lazy_migrate/new_migrator_adapter.rb', line 32
def down(version)
context.run(:down, version)
end
|
#migrate(version) ⇒ Object
43
44
45
|
# File 'lib/lazy_migrate/new_migrator_adapter.rb', line 43
def migrate(version)
context.up(version)
end
|
#redo(version) ⇒ Object
37
38
39
40
|
# File 'lib/lazy_migrate/new_migrator_adapter.rb', line 37
def redo(version)
down(version)
up(version)
end
|
#rollback(version) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/lazy_migrate/new_migrator_adapter.rb', line 48
def rollback(version)
previous_version = find_previous_version(version)
if previous_version.nil?
down(version)
else
context.down(previous_version)
end
end
|
#up(version) ⇒ Object
27
28
29
|
# File 'lib/lazy_migrate/new_migrator_adapter.rb', line 27
def up(version)
context.run(:up, version)
end
|