Module: Ronin::Database::Migrations
- Extended by:
- DataMapper::Property::Lookup
- Defined in:
- lib/ronin/database/migrations/1.0.0.rb,
lib/ronin/database/migrations/1.1.0.rb,
lib/ronin/database/migrations/graph.rb,
lib/ronin/database/migrations/migration.rb,
lib/ronin/database/migrations/migrations.rb,
lib/ronin/database/migrations/exceptions/unknown_migration.rb,
lib/ronin/database/migrations/exceptions/duplicate_migration.rb
Defined Under Namespace
Classes: DuplicateMigration, Graph, Migration, UnknownMigration
Class Method Summary collapse
-
.migrate_down!(position_or_name = nil) ⇒ true
private
Migrates the database downwards to a certain migration position or name.
-
.migrate_up!(position_or_name = nil) ⇒ true
private
Migrates the database upward to a given migration position or name.
-
.migration(*arguments) { ... } ⇒ Migration
Defines a new migration.
-
.migrations ⇒ Graph
private
The defined migrations.
Class Method Details
.migrate_down!(position_or_name = nil) ⇒ true
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.
Migrates the database downwards to a certain migration position or name.
176 177 178 179 180 181 182 |
# File 'lib/ronin/database/migrations/migrations.rb', line 176 def self.migrate_down!(position_or_name=nil) self.migrations.downto(position_or_name) do |migration| migration.perform_down end return true end |
.migrate_up!(position_or_name = nil) ⇒ true
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.
Migrates the database upward to a given migration position or name.
151 152 153 154 155 156 157 |
# File 'lib/ronin/database/migrations/migrations.rb', line 151 def self.migrate_up!(position_or_name=nil) self.migrations.upto(position_or_name) do |migration| migration.perform_up end return true end |
.migration(*arguments) { ... } ⇒ Migration
Its recommended that you stick with raw SQL for migrations that manipulate data. If you write a migration using a model, then later change the model, there's a possibility the migration will no longer work. Using SQL will always work.
Defines a new migration.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/ronin/database/migrations/migrations.rb', line 117 def self.migration(*arguments,&block) case arguments[0] when Integer position = arguments[0] name = arguments[1] = (arguments[2] || {}) self.migrations.migration_at(position,name,,&block) when Symbol, String name = arguments[0] = (arguments[1] || {}) self.migrations.migration_named(name,,&block) else raise(ArgumentError,"first argument must be an Integer, Symbol or a String",caller) end end |
.migrations ⇒ Graph
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 defined migrations.
39 40 41 |
# File 'lib/ronin/database/migrations/migrations.rb', line 39 def self.migrations @migrations ||= Graph.new end |