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
Defined Under Namespace
Classes: InlineRunner, Migrator, Recorder, Runner, SchemaDiff, Writer
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
- #auto_migrate!(conf, options = EMPTY_HASH, &block) ⇒ Object
- #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.
97 98 99 |
# File 'lib/rom/sql/migration.rb', line 97 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
87 88 89 90 91 |
# File 'lib/rom/sql/migration.rb', line 87 def self.included(base) super base.singleton_class.send(:attr_accessor, :instance) end |
Instance Method Details
#auto_migrate!(conf, options = EMPTY_HASH, &block) ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/rom/sql/migration.rb', line 142 def auto_migrate!(conf, = EMPTY_HASH, &block) schemas = conf.relation_classes(self).map do |klass| klass.schema_proc.call.finalize_attributes!(gateway: self) end migrator.auto_migrate!(self, schemas, ) end |
#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.
100 101 102 103 104 |
# File 'lib/rom/sql/migration.rb', line 100 def initialize(uri, = EMPTY_HASH) @migrator = .fetch(:migrator) { Migrator.new(connection) } self.class.instance ||= self end |
#migration(&block) ⇒ Object
Migration DSL
122 123 124 |
# File 'lib/rom/sql/migration.rb', line 122 def migration(&block) migrator.migration(&block) end |
#pending_migrations? ⇒ Boolean
Check if there are any pending migrations
111 112 113 114 115 |
# File 'lib/rom/sql/migration.rb', line 111 def pending_migrations? ROM::SQL.with_gateway(self) { migrator.pending? } end |
#run_migrations(options = {}) ⇒ Object
Run migrations
135 136 137 138 139 |
# File 'lib/rom/sql/migration.rb', line 135 def run_migrations( = {}) ROM::SQL.with_gateway(self) { migrator.run() } end |