Skip to content

Conversation

@NielsKSchjoedt
Copy link

@NielsKSchjoedt NielsKSchjoedt commented Nov 25, 2014

  • Fix: Remove CREATE SCHEMA clause for default_schema from structure dump definition.
  • Improve: The structure dump now points foreign key constrains that references excluded_models to default_schema instead of the new schema.

_An example_

With a config like this:

Apartment.configure do |config|
  config.excluded_models = ["User"]
  config.use_schemas = true
  config.use_sql = true
  config.persistent_schemas = ['extensions']
  config.default_schema = 'da'
  config.tenant_names = ['da', 'se', 'us']
end

The definitions will now look like this:

ALTER TABLE ONLY feedbacks
    ADD CONSTRAINT feedbacks_user_id_fk FOREIGN KEY (user_id) REFERENCES da.users(id) ON DELETE CASCADE;

Instead of this:

ALTER TABLE ONLY feedbacks
    ADD CONSTRAINT feedbacks_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;

Conflicts:
	lib/apartment/adapters/postgresql_adapter.rb
Conflicts:
	lib/apartment/adapters/postgresql_adapter.rb
@mikecmpbll
Copy link
Collaborator

why doesn't pg_dump dump foreign key constraints that reference other schemas properly? and why does it include a definition for the default schema?

apologies if they're silly questions, i'm not that familiar with pg yet :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants