Open ArnisL opened 5 years ago
Same issue with Rails 5.2.2 and Ruby 2.5.3
It seems like newer versions of pg_dump will always include CREATE SCHEMA public;
if specifying a schema on the command line.
I ran into something similar while working on an external application for provisioning tenants where create schema command would be included for non public schemas, I ended up replacing the create schema calls in swap_schema_qualifier
new_sql.gsub!(/CREATE SCHEMA #{@source_schema}\;/, '')
I could be worth adding CREATE SCHEMA
to the pg dump block list, but there might be some setups where creating more then one schema per tenant is a valid use case? https://github.com/influitive/apartment/blob/a4332c3222210b11f5e8c27fa4c1a18b492e9629/lib/apartment/adapters/postgresql_adapter.rb#L108-L113
@tappleby thanks for your feedback, I just used the latter approach for a lokal money patch.
does 927ba21a3092b8e4525ccd3ce8f9d7a3ba2afdd1 wich is included in v2.2.1 fixes this finally?
Steps to reproduce
Apartment::Tenant.create('test')
Expected behavior
create a new tenant named test
Actual behavior
apparently "forgets" the name and tries to create another "public" schema
System configuration
arch linux something
Database: (Tell us what database and its version you use.) Postgresql 11.1
Apartment version: 2.2.0
Apartment config (in
config/initializers/apartment.rb
or so):use_schemas
: (true
orfalse
) trueRails (or ActiveRecord) version: 5.0.6
Ruby version: 2.3.3