class Para::PostgresExtensionsChecker

Public Class Methods

check_all() click to toggle source
# File lib/para/postgres_extensions_checker.rb, line 4
def check_all
  Para::LogConfig.with_log_level(:fatal) do
    %w(hstore unaccent).each do |extname|
      unless extension_exists?(extname)
        # Could not use Rails.logger here, using puts as a temporary
        # solution.
        puts "[Warning] PostgreSQL \"#{ extname }\" extension is not " +
             "installed in your database. This means that you " +
             "missing some migrations that you can install " +
             "with the following command : " +
             "`rake para_engine:install:migrations` and then migrate."
      end
    end
  end
end

Private Class Methods

extension_exists?(extname) click to toggle source
# File lib/para/postgres_extensions_checker.rb, line 22
def extension_exists?(extname)
  result = ActiveRecord::Base.connection.execute(
    "SELECT COUNT(*) FROM pg_catalog.pg_extension " +
    "WHERE extname = '#{ extname }'"
  ).first

  result && result['count'].to_i > 0
rescue ActiveRecord::NoDatabaseError
  true # Do not issue warning when no database is installed
end