Module: ROM::SQL::Migration

Included in:
Gateway
Defined in:
lib/rom/sql/migration.rb,
lib/rom/sql/migration/runner.rb,
lib/rom/sql/migration/writer.rb,
lib/rom/sql/migration/migrator.rb,
lib/rom/sql/migration/recorder.rb,
lib/rom/sql/migration/schema_diff.rb,
lib/rom/sql/migration/inline_runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#migratorObject (readonly)

Returns the value of attribute migrator.



99
100
101
# File 'lib/rom/sql/migration.rb', line 99

def migrator
  @migrator
end

Instance Method Details

#auto_migrate!(conf, options = EMPTY_HASH) ⇒ Object



144
145
146
147
148
149
150
# File 'lib/rom/sql/migration.rb', line 144

def auto_migrate!(conf, options = EMPTY_HASH)
  schemas = conf.relation_classes(self).map do |klass|
    klass.schema_proc.call.finalize_attributes!(gateway: self)
  end

  migrator.auto_migrate!(self, schemas, options)
end

#migration(&block) ⇒ Object

Migration DSL

See Also:



124
125
126
# File 'lib/rom/sql/migration.rb', line 124

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

#pending_migrations?Boolean

Check if there are any pending migrations

Returns:

  • (Boolean)

See Also:

  • pending?


113
114
115
116
117
# File 'lib/rom/sql/migration.rb', line 113

def pending_migrations?
  ROM::SQL.with_gateway(self) {
    migrator.pending?
  }
end

#run_migrations(options = {}) ⇒ Object

Run migrations

Examples:

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

Parameters:

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

    The options used by Sequel migrator



137
138
139
140
141
# File 'lib/rom/sql/migration.rb', line 137

def run_migrations(options = {})
  ROM::SQL.with_gateway(self) {
    migrator.run(options)
  }
end