Module: Mack::Database::Migrations

Defined in:
lib/mack-active_record/database_migrations.rb

Class Method Summary collapse

Class Method Details

.abort_if_pending_migrationsObject

Not implemented



19
20
# File 'lib/mack-active_record/database_migrations.rb', line 19

def self.abort_if_pending_migrations
end

.migrateObject

Migrates the database to the latest version



6
7
8
# File 'lib/mack-active_record/database_migrations.rb', line 6

def self.migrate
  ActiveRecord::Migrator.up(Mack::Paths.db("migrations"))
end

.rollback(step = 1) ⇒ Object

Rolls back the database by the specified number of steps. Default is 1



11
12
13
14
15
16
# File 'lib/mack-active_record/database_migrations.rb', line 11

def self.rollback(step = 1)
  cur_version = version.to_i
  target_version = cur_version - step 
  target_version = 0 if target_version < 0
  ActiveRecord::Migrator.down(Mack::Paths.db("migrations"), target_version)
end

.versionObject

Returns the current version of the database



23
24
25
# File 'lib/mack-active_record/database_migrations.rb', line 23

def self.version
  ActiveRecord::Migrator.current_version
end