5 # :title: journal backend for postgresql
13 class PostgresStorage < AbstractStorage
14 def initialize(opts={})
15 @uri = opts[:uri] || 'postgresql://localhost/rbot_journal'
16 @conn = PG.connect(@uri)
17 @version = @conn.exec('SHOW server_version;')[0]['server_version']
19 @version.gsub!(/^(\d+\.\d+)$/, '\1.0')
20 log 'journal storage: postgresql connected to version: ' + @version
22 version = @version.split('.')[0,3].join.to_i
24 raise StorageError.new(
25 'PostgreSQL Version too old: %s, supported: >= 9.3' % [@version])
27 @jsonb = (version >= 940)
28 log 'journal storage: no jsonb support, consider upgrading postgres'