class Apartment::Adapters::JDBCPostgresqlSchemaAdapter

Separate Adapter for Postgresql when using schemas

def connect_to_new(tenant = nil)


Set schema search path to new schema
def connect_to_new(tenant = nil)
  return reset if tenant.nil?
  raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless schema_exists?(tenant)
  @current = tenant.is_a?(Array) ? tenant.map(&:to_s) : tenant.to_s
  Apartment.connection.schema_search_path = full_search_path
rescue ActiveRecord::StatementInvalid, ActiveRecord::JDBCError
  raise TenantNotFound, "One of the following schema(s) is invalid: #{full_search_path}"
end

def rescue_from

def rescue_from
  ActiveRecord::JDBCError
end

def tenant_exists?(tenant)

def tenant_exists?(tenant)
  return true unless Apartment.tenant_presence_check
  Apartment.connection.all_schemas.include? tenant
end