diff --git a/lib/apartment/adapters/postgresql_adapter.rb b/lib/apartment/adapters/postgresql_adapter.rb index e1b57f06..23e3fd50 100644 --- a/lib/apartment/adapters/postgresql_adapter.rb +++ b/lib/apartment/adapters/postgresql_adapter.rb @@ -63,18 +63,10 @@ def drop_command(conn, tenant) # def connect_to_new(tenant = nil) return reset if tenant.nil? - raise ActiveRecord::StatementInvalid.new("Could not find schema #{tenant}") unless Apartment.connection.schema_exists?(tenant.to_s) - + @current = tenant.to_s Apartment.connection.schema_search_path = full_search_path - # When the PostgreSQL version is < 9.3, - # there is a issue for prepared statement with changing search_path. - # https://www.postgresql.org/docs/9.3/static/sql-prepare.html - if postgresql_version < 90300 - Apartment.connection.clear_cache! - end - rescue *rescuable_exceptions raise TenantNotFound, "One of the following schema(s) is invalid: \"#{tenant}\" #{full_search_path}" end