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) ⇒ 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.
99 100 101 |
# File 'lib/rom/sql/migration.rb', line 99 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
89 90 91 92 93 |
# File 'lib/rom/sql/migration.rb', line 89 def self.included(base) super base.singleton_class.send(:attr_accessor, :instance) 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, = EMPTY_HASH) 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.
102 103 104 105 106 |
# File 'lib/rom/sql/migration.rb', line 102 def initialize(_uri, = EMPTY_HASH) @migrator = create_migrator([:migrator]) self.class.instance ||= self end |
#migration(&block) ⇒ Object
Migration DSL
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
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
137 138 139 140 141 |
# File 'lib/rom/sql/migration.rb', line 137 def run_migrations( = {}) ROM::SQL.with_gateway(self) { migrator.run() } end |