Sha256: 75ccff2bf9d900ad7a8c98e0493aa382db3926b3f41b139d7444377ec3e6e8a4

Contents?: true

Size: 1.11 KB

Versions: 47

Compression:

Stored size: 1.11 KB

Contents

module Para
  class PostgresExtensionsChecker
    class << self
      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

      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
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
para-0.12.4 lib/para/postgres_extensions_checker.rb
para-0.12.3 lib/para/postgres_extensions_checker.rb
para-0.12.2 lib/para/postgres_extensions_checker.rb
para-0.12.1 lib/para/postgres_extensions_checker.rb
para-0.12.0 lib/para/postgres_extensions_checker.rb
para-0.11.4 lib/para/postgres_extensions_checker.rb
para-0.11.3 lib/para/postgres_extensions_checker.rb
para-0.11.2 lib/para/postgres_extensions_checker.rb
para-0.11.1 lib/para/postgres_extensions_checker.rb
para-0.11.0 lib/para/postgres_extensions_checker.rb
para-0.10.0 lib/para/postgres_extensions_checker.rb
para-0.9.4 lib/para/postgres_extensions_checker.rb
para-0.9.3.3 lib/para/postgres_extensions_checker.rb
para-0.9.3.2 lib/para/postgres_extensions_checker.rb
para-0.9.3.1 lib/para/postgres_extensions_checker.rb
para-0.9.2 lib/para/postgres_extensions_checker.rb
para-0.9.0 lib/para/postgres_extensions_checker.rb
para-0.8.15 lib/para/postgres_extensions_checker.rb
para-0.8.14 lib/para/postgres_extensions_checker.rb
para-0.8.13 lib/para/postgres_extensions_checker.rb