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

Foreign key issue #43

Open
dima12qw opened this issue Jul 25, 2017 · 3 comments
Open

Foreign key issue #43

dima12qw opened this issue Jul 25, 2017 · 3 comments

Comments

@dima12qw
Copy link

Hi. I have one question. If I create a table that have a foreign key references to tenant's table (fk_id_tenant). How can I create this relation?

@Dania02525
Copy link
Owner

If this is a tenant table, you can simply use references(:tablename) The current opts hash for references function in Ecto doesn't seem to support the prefix option (which would allow you to use a foreign key referencing a different schema than the tenant's schema.

See here: https://hexdocs.pm/ecto/Ecto.Migration.html#references/2

Does that answer your question?

@FabienHenon
Copy link

Is there any workaround to create a reference on another schema? Like using execute tu manually create it?

@BenMorganIO
Copy link
Contributor

@FabienHenon I believe that's against the nature of tenants. Each tenant is their own isolated DB. You can add the foreign key, but I don't believe you'll be able to use a foreign key constraint in PG.

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

No branches or pull requests

4 participants