diff options
author | Matthias Hecker <apoc@geekosphere.org> | 2015-06-14 03:01:25 +0200 |
---|---|---|
committer | Matthias Hecker <apoc@geekosphere.org> | 2015-06-14 03:01:25 +0200 |
commit | 830c8d7d6be5d0bda2df05ff5a2383362e39f8d4 (patch) | |
tree | 6c131322968b0ea9f351ac7537f082613a8bbad4 /lib/rbot/journal | |
parent | d864b0348f25d845fa312cedfd5011b2d25022dc (diff) |
journal: started implementing postgres storage
Diffstat (limited to 'lib/rbot/journal')
-rw-r--r-- | lib/rbot/journal/postgres.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/rbot/journal/postgres.rb b/lib/rbot/journal/postgres.rb new file mode 100644 index 00000000..85514fb2 --- /dev/null +++ b/lib/rbot/journal/postgres.rb @@ -0,0 +1,39 @@ +# encoding: UTF-8 +#-- vim:sw=2:et +#++ +# +# :title: journal backend for postgresql + +require 'pg' + +module Irc +class Bot +module Journal + module Storage + class PostgresStorage < AbstractStorage + def initialize(opts={}) + @uri = opts[:uri] || 'postgresql://localhost/rbot_journal' + @conn = PG.connect(@uri) + @version = @conn.exec('SHOW server_version;')[0]['server_version'] + + @version.gsub!(/^(\d+\.\d+)$/, '\1.0') + log 'journal storage: postgresql connected to version: ' + @version + + version = @version.split('.')[0,3].join.to_i + if version < 930 + raise StorageError.new( + 'PostgreSQL Version too old: %s, supported: >= 9.3' % [@version]) + end + @jsonb = (version >= 940) + log 'journal storage: no jsonb support, consider upgrading postgres' + + create_table + end + + def create_table + end + end + end +end # Journal +end # Bot +end # Irc |