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

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.connectionObject

Returns the value of attribute connection.



74
75
76
# File 'lib/rom/sql/migration.rb', line 74

def connection
  @connection
end

.pathObject



76
77
78
# File 'lib/rom/sql/migration.rb', line 76

def path
  @path || Migrator::DEFAULT_PATH
end

Class Method Details

.create(&block) ⇒ Object



85
86
87
88
# File 'lib/rom/sql/migration.rb', line 85

def create(&block)
  warn "ROM::SQL::Migration.create is deprecated please use ROM::SQL.migration (#{caller[0]})"
  ::Sequel.migration(&block)
end

.included(klass) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/rom/sql/migration.rb', line 33

def self.included(klass)
  super
  klass.class_eval do
    option :migrator, reader: true, default: proc { |gateway|
      Migrator.new(gateway.connection)
    }
  end
end

.run(options = {}) ⇒ Object



80
81
82
83
# File 'lib/rom/sql/migration.rb', line 80

def run(options = {})
  warn "ROM::SQL::Migration.run is deprecated please ROM::SQL::Gateway#run_migrations (#{caller[0]})"
  ::Sequel::Migrator.run(connection, path, options)
end

Instance Method Details

#migration(&block) ⇒ Object

See Also:



52
53
54
# File 'lib/rom/sql/migration.rb', line 52

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

#pending_migrations?Boolean

Returns:

  • (Boolean)

See Also:

  • pending?


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

def pending_migrations?
  migrator.pending?
end

#run_migrations(options = {}) ⇒ Object

Run migrations for a given gateway

Examples:

ROM.setup(:sql, ['sqlite::memory'])
ROM.finalize
ROM.env.gateways[:default].run_migrations

Parameters:

  • options (Hash) (defaults to: {})

    The options used by Sequel migrator



67
68
69
# File 'lib/rom/sql/migration.rb', line 67

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