Class: Bizflow::SetupCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/bizflow/command/setup_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
29
30
31
32
# File 'lib/bizflow/command/setup_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

  # Create a database
  puts "Bizflow: Creating and migrating database for processes..."

  db_path = "bizflow_db/bf-#{environment}.db"
  db_path = "#{Dir.pwd}/#{db_path}"

  pn = Pathname.new(db_path)
  FileUtils::mkdir_p pn.dirname.to_s

  db = Sequel.sqlite(db_path)

  Sequel::Migrator.run(db, File.expand_path("#{File.expand_path(File.dirname(__FILE__))}/../migrations"), :use_transactions=>true)

  puts "Bizflow: #{environment} database setup"
end