Sha256: 1a345a42b42fe9d229a830f2b339e3257b0fdad1a8a31d06930c2e95895d0fe6

Contents?: true

Size: 420 Bytes

Versions: 3

Compression:

Stored size: 420 Bytes

Contents

module TestData
  class DetectsDatabaseExistence
    def initialize
      @config = TestData.config
    end

    def call
      rows = ActiveRecord::Base.connection.execute <<~SQL
        select datname database_name
        from pg_catalog.pg_database
      SQL
      rows.any? { |row|
        row["database_name"] == @config.database_name
      }
    rescue ActiveRecord::NoDatabaseError
      false
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
test_data-0.3.2 lib/test_data/detects_database_existence.rb
test_data-0.3.1 lib/test_data/detects_database_existence.rb
test_data-0.3.0 lib/test_data/detects_database_existence.rb