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
-
#migrator ⇒ Object
readonly
Returns the value of attribute migrator.
Class Method Summary collapse
-
.included(base) ⇒ Object
private
FIXME: remove in 2.0.
Instance Method Summary collapse
- #initialize(uri, options = EMPTY_HASH) ⇒ Object private
-
#migration(&block) ⇒ Object
Migration DSL.
-
#pending_migrations? ⇒ Boolean
Check if there are any pending migrations.
-
#run_migrations(options = {}) ⇒ Object
Run migrations.
Instance Attribute Details
#migrator ⇒ Object (readonly)
Returns the value of attribute migrator.
95 96 97 |
# File 'lib/rom/sql/migration.rb', line 95 def migrator @migrator end |
Class Method Details
.included(base) ⇒ 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.
FIXME: remove in 2.0
85 86 87 88 89 |
# File 'lib/rom/sql/migration.rb', line 85 def self.included(base) super base.singleton_class.send(:attr_accessor, :instance) 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.
98 99 100 101 102 |
# File 'lib/rom/sql/migration.rb', line 98 def initialize(uri, = EMPTY_HASH) @migrator = .fetch(:migrator) { Migrator.new(connection) } self.class.instance ||= self end |
#migration(&block) ⇒ Object
Migration DSL
120 121 122 |
# File 'lib/rom/sql/migration.rb', line 120 def migration(&block) migrator.migration(&block) end |
#pending_migrations? ⇒ Boolean
Check if there are any pending migrations
109 110 111 112 113 |
# File 'lib/rom/sql/migration.rb', line 109 def pending_migrations? ROM::SQL.with_gateway(self) { migrator.pending? } end |
#run_migrations(options = {}) ⇒ Object
Run migrations
133 134 135 136 137 |
# File 'lib/rom/sql/migration.rb', line 133 def run_migrations( = {}) ROM::SQL.with_gateway(self) { migrator.run() } end |