Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Postgresql adapter when using Apartment.use_sql and Apartment.use_schemas #182

Open
wants to merge 7 commits into
base: development
Choose a base branch
from

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.

None yet

2 participants