Class: Bizflow::MigrateCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/bizflow/command/migrate_command.rb

Class Method Summary collapse

Class Method Details

.run(config, args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bizflow/command/migrate_command.rb', line 9

def self.run(config, args)

  if(args[:args].empty?)
    raise "Setup command needs environment argument (production, development, test...)"
  end
  environment = args[:args].first

  Sequel.extension :migration, :core_extensions

  puts "Bizflow: Migrating database"
  db_path = config[:db_path] || "bizflow_db"
  db_path = "#{Dir.pwd}/#{db_path}/bf-#{environment}.db"

  puts db_path
  db = Sequel.sqlite(db_path)

  Sequel::Migrator.run(db, File.expand_path("#{File.expand_path(File.dirname(__FILE__))}/../migrations"), :use_transactions=>true)
  puts "Bizflow: Database bf-#{environment}.db migrated"

end