Method: Gleis::Database.psql

Defined in:
lib/gleis/database.rb

.psql(app_name) ⇒ Object



103
104
105
106
107
108
109
110
# File 'lib/gleis/database.rb', line 103

def self.psql(app_name)
  token = Token.check
  abort('The PostgreSQL client psql is not installed on this system.') unless Utils.which('psql')
  url = Config.get_env_var(app_name, token, 'DATABASE_URL')
  abort('There is no database configured under the DATABASE_URL variable.') unless url
  ENV['PGCONNECT_TIMEOUT'] = '5'
  exec("psql #{url}")
end