19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/dorothy2/do-utils.rb', line 19
def init_db(ddl=DoroSettings.dorothive[:ddl], force=false)
LOGGER.warn "DB", "The database is going to be initialized with the file #{ddl}. If the Dorothive is already present, " + "all the its data will be lost".red + ". Continue?(write yes)"
answ = "yes"
answ = gets.chop unless force
if answ == "yes"
begin
raise 'An error occurred' unless system "psql -h #{DoroSettings.dorothive[:dbhost]} -U #{DoroSettings.dorothive[:dbuser]} -f #{ddl} 1> /dev/null"
LOGGER.info "DB", "Database correctly initialized. Now you can restart Dorothy!"
rescue => e
LOGGER.error "DB", $!
LOGGER.debug "DB", e.inspect
end
else
LOGGER.error "DB", "Database untouched, quitting."
end
end
|