Class: Vines::Command::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/vines/command/schema.rb

Instance Method Summary collapse

Instance Method Details

#run(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vines/command/schema.rb', line 6

def run(opts)
  raise 'vines schema <domain>' unless opts[:args].size == 1
  require opts[:config]
  domain = opts[:args].first
  unless storage = Config.instance.vhost(domain).storage rescue nil
    raise "#{domain} virtual host not found in conf/config.rb"
  end
  unless storage.respond_to?(:create_schema)
    raise "SQL storage not configured for #{domain} virtual host"
  end
  begin
    storage.create_schema
  rescue => e
    raise "Schema creation failed: #{e.message}"
  end
end