Class: BazaMigrations::Migration
- Inherits:
-
Object
- Object
- BazaMigrations::Migration
- Defined in:
- lib/baza_migrations/migration.rb
Instance Method Summary collapse
- #change ⇒ Object
- #down ⇒ Object
-
#initialize(args = {}) ⇒ Migration
constructor
A new instance of Migration.
- #migrate(direction) ⇒ Object
- #up ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Migration
Returns a new instance of Migration.
2 3 4 5 6 |
# File 'lib/baza_migrations/migration.rb', line 2 def initialize(args = {}) @db = args.fetch(:db) raise "No database was given" unless @db @changes = [] end |
Instance Method Details
#change ⇒ Object
8 9 10 |
# File 'lib/baza_migrations/migration.rb', line 8 def change raise BazaMigrations::Errors::NotImplementedError end |
#down ⇒ Object
16 17 18 |
# File 'lib/baza_migrations/migration.rb', line 16 def down raise BazaMigrations::Errors::NotImplementedError end |
#migrate(direction) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/baza_migrations/migration.rb', line 20 def migrate(direction) if direction == :up begin up execute_changes rescue BazaMigrations::Errors::NotImplementedError change execute_changes end elsif direction == :down begin down execute_changes rescue BazaMigrations::Errors::NotImplementedError change rollback_changed_changes end else raise "Invalid direction: #{direction}" end @changes = [] end |
#up ⇒ Object
12 13 14 |
# File 'lib/baza_migrations/migration.rb', line 12 def up raise BazaMigrations::Errors::NotImplementedError end |