Module: Innkeeper::Migrator
Instance Method Summary collapse
-
#migrate(database) ⇒ Object
Migrate to latest.
-
#rollback(database, step = 1) ⇒ Object
rollback latest migration ‘step` number of times.
-
#run(direction, database, version) ⇒ Object
Migrate up/down to a specific version.
Instance Method Details
#migrate(database) ⇒ Object
Migrate to latest
9 10 11 12 13 14 15 16 17 |
# File 'lib/innkeeper/migrator.rb', line 9 def migrate(database) Tenant.switch(database) do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, version) do |migration| ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope) end end end |
#rollback(database, step = 1) ⇒ Object
rollback latest migration ‘step` number of times
27 28 29 30 31 |
# File 'lib/innkeeper/migrator.rb', line 27 def rollback(database, step = 1) Tenant.switch(database) do ActiveRecord::Migrator.rollback(ActiveRecord::Migrator.migrations_paths, step) end end |
#run(direction, database, version) ⇒ Object
Migrate up/down to a specific version
20 21 22 23 24 |
# File 'lib/innkeeper/migrator.rb', line 20 def run(direction, database, version) Tenant.switch(database) do ActiveRecord::Migrator.run(direction, ActiveRecord::Migrator.migrations_paths, version) end end |