module Upknit::ConnectionExtension::PostgreSQL

An extension to ActiveRecord::ConnectionAdapters::PostgresqlAdapter

When included, this module adds two methods to support UUID extension.

Constants

UUID_EXTENSIONS

UUID support extensions in desired order Note: Use of uuid-ossp for random UUID(v4) is discouraged www.postgresql.org/docs/9.6/static/uuid-ossp.html

Public Instance Methods

enable_uuid() click to toggle source

Enables an extension which adds UUID function to the system. @return [void]

# File lib/upknit/connection_extension/postgresql.rb, line 11
def enable_uuid
  enable_extension(uuid_extension)
end
uuid_extension() click to toggle source

Returns the name of UUID extension which should be used in current connection. @return [String] Name of the extension

# File lib/upknit/connection_extension/postgresql.rb, line 17
def uuid_extension
  (UUID_EXTENSIONS & available_extensions).first
end

Private Instance Methods

available_extensions() click to toggle source
# File lib/upknit/connection_extension/postgresql.rb, line 29
def available_extensions
  exec_query('SELECT Name FROM pg_available_extensions').cast_values
end