Module: ROM::SQL::Migration

Included in:
Gateway
Defined in:
lib/rom/sql/migration.rb,
lib/rom/sql/migration/migrator.rb

Defined Under Namespace

Classes: Migrator

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#migratorObject (readonly)

Returns the value of attribute migrator.



44
45
46
# File 'lib/rom/sql/migration.rb', line 44

def migrator
  @migrator
end

Instance Method Details

#initialize(uri, options = EMPTY_HASH) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



47
48
49
# File 'lib/rom/sql/migration.rb', line 47

def initialize(uri, options = EMPTY_HASH)
  @migrator = options.fetch(:migrator) { Migrator.new(connection) }
end

#migration(&block) ⇒ Object

Migration DSL

See Also:



65
66
67
# File 'lib/rom/sql/migration.rb', line 65

def migration(&block)
  migrator.migration(&block)
end

#pending_migrations?Boolean

Check if there are any pending migrations

See Also:

  • pending?


56
57
58
# File 'lib/rom/sql/migration.rb', line 56

def pending_migrations?
  migrator.pending?
end

#run_migrations(options = {}) ⇒ Object

Run migrations

Examples:

rom = ROM.container(:sql, ['sqlite::memory'])
rom.gateways[:default].run_migrations


78
79
80
# File 'lib/rom/sql/migration.rb', line 78

def run_migrations(options = {})
  migrator.run(options)
end