Module: Ronin::DB::Migrations
- Defined in:
- lib/ronin/db/migrations.rb
Overview
Handles migrating the database.
Constant Summary collapse
- DIR =
Path to the
db/migrate/
directory inronin-db-activerecord
. File.('../../../db/migrate',__dir__)
Class Method Summary collapse
-
.context ⇒ ActiveRecord::MigrationContext
private
The migration context.
-
.current_version ⇒ Integer
The current migration version of the database.
-
.down(target_version = nil, &block) ⇒ Object
Explicitly migrates down the database to the target version.
-
.foreward(steps = 1) ⇒ Object
Applies the next number of migrations.
-
.migrate(target_version = nil) ⇒ Object
Migrates the database to the target version.
-
.needs_migration? ⇒ Boolean
Determines if the database needs migrating up.
-
.rollback(steps = 1) ⇒ Object
Rollbacks the last number of migrations.
-
.up(target_version = nil, &block) ⇒ Object
Explicitly migrates up the database to the target version.
Class Method Details
.context ⇒ ActiveRecord::MigrationContext
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.
The migration context.
118 119 120 |
# File 'lib/ronin/db/migrations.rb', line 118 def self.context @context ||= ActiveRecord::MigrationContext.new([DIR]) end |
.current_version ⇒ Integer
The current migration version of the database.
35 36 37 |
# File 'lib/ronin/db/migrations.rb', line 35 def self.current_version context.current_version end |
.down(target_version = nil, &block) ⇒ Object
Explicitly migrates down the database to the target version.
80 81 82 |
# File 'lib/ronin/db/migrations.rb', line 80 def self.down(target_version=nil,&block) context.down(target_version,&block) end |
.foreward(steps = 1) ⇒ Object
Applies the next number of migrations.
104 105 106 |
# File 'lib/ronin/db/migrations.rb', line 104 def self.foreward(steps=1) context.foreward(steps) end |
.migrate(target_version = nil) ⇒ Object
Migrates the database to the target version.
56 57 58 |
# File 'lib/ronin/db/migrations.rb', line 56 def self.migrate(target_version=nil) context.migrate(target_version) end |
.needs_migration? ⇒ Boolean
Determines if the database needs migrating up.
44 45 46 |
# File 'lib/ronin/db/migrations.rb', line 44 def self.needs_migration? context.needs_migration? end |
.rollback(steps = 1) ⇒ Object
Rollbacks the last number of migrations.
92 93 94 |
# File 'lib/ronin/db/migrations.rb', line 92 def self.rollback(steps=1) context.rollback(steps) end |
.up(target_version = nil, &block) ⇒ Object
Explicitly migrates up the database to the target version.
68 69 70 |
# File 'lib/ronin/db/migrations.rb', line 68 def self.up(target_version=nil,&block) context.up(target_version,&block) end |