class PhilColumns::Migrator

Attributes

config[R]

Public Class Methods

new( config ) click to toggle source
# File lib/phil_columns/migrator.rb, line 7
def initialize( config )
  @backend = PhilColumns::migrator_klass.new
  @config  = config
end

Public Instance Methods

clear_migrations_table() click to toggle source
# File lib/phil_columns/migrator.rb, line 12
def clear_migrations_table
  raise( *error ) unless backend_responds?( :clear_migrations_table )
  backend.send :clear_migrations_table
end
down( version=0 ) click to toggle source
# File lib/phil_columns/migrator.rb, line 17
def down( version=0 )
  raise( *error ) unless backend_responds?( :down )
  backend.send :down, version
end
drop_table( table ) click to toggle source
# File lib/phil_columns/migrator.rb, line 22
def drop_table( table )
  raise( *error ) unless backend_responds?( :drop_table )
  backend.send :drop_table, table
end
drop_tables() click to toggle source
# File lib/phil_columns/migrator.rb, line 27
def drop_tables
  raise( *error ) unless backend_responds?( :drop_tables )
  backend.send :drop_tables
end
latest_version() click to toggle source
# File lib/phil_columns/migrator.rb, line 32
def latest_version
  raise( *error ) unless backend_responds?( :latest_version )
  backend.send :latest_version
end
load_schema() click to toggle source
# File lib/phil_columns/migrator.rb, line 37
def load_schema
  raise( *error ) unless backend_responds?( :load_schema )
  backend.send :load_schema
end
mulligan() click to toggle source
# File lib/phil_columns/migrator.rb, line 42
def mulligan
  if config.schema_unload_strategy == 'drop'
    confirm "Dropping all tables ... ", :cyan do
      drop_tables
      clear_migrations_table
    end
  else
    confirm "Migrating DB to version 0 ... ", :cyan do
      down
    end
  end

  if config.schema_load_strategy == 'load'
    confirm "Loading schema ... ", :cyan do
      load_schema
    end
  else
    confirm "Migrating DB to latest version ... ", :cyan do
      up
    end
  end
end
tables() click to toggle source
# File lib/phil_columns/migrator.rb, line 65
def tables
  raise( *error ) unless backend_responds?( :tables )
  backend.send :tables
end
up( version=nil ) click to toggle source
# File lib/phil_columns/migrator.rb, line 70
def up( version=nil )
  raise( *error ) unless backend_responds?( :up )
  backend.send :up, version
end