Module: Mack::Database::Migrations

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

Class Method Summary collapse

Class Method Details

.abort_if_pending_migrationsObject

Raises:

  • (NoMethodError)


15
16
17
# File 'lib/mack-orm/database_migrations.rb', line 15

def self.abort_if_pending_migrations
  raise NoMethodError.new(:abort_if_pending_migrations)
end

.migrateObject

Migrates the database to the latest version

Raises:

  • (NoMethodError)


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

def self.migrate
  raise NoMethodError.new(:migrate)
end

.migration_filesObject

Returns a list of the all migration files.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mack-orm/database_migrations.rb', line 25

def self.migration_files
  allmigs = {}
  Mack.search_path_local_first(:db).each do |path|
    Dir.glob(File.join(path, 'migrations', '*.rb')).each do |f|
      base = File.basename(f).match(/\d+_(.+)/).captures.first.downcase
      unless allmigs[base]
        allmigs[base] = f
      end
    end
  end
  allmigs.collect {|k,v| v}.sort
end

.rollback(step = 1) ⇒ Object

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

Raises:

  • (NoMethodError)


11
12
13
# File 'lib/mack-orm/database_migrations.rb', line 11

def self.rollback(step = 1)
  raise NoMethodError.new(:rollback)
end

.versionObject

Returns the current version of the database

Raises:

  • (NoMethodError)


20
21
22
# File 'lib/mack-orm/database_migrations.rb', line 20

def self.version
  raise NoMethodError.new(:version)
end