apartmentex
apartmentex copied to clipboard
Foreign key issue
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?
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?
Is there any workaround to create a reference on another schema? Like using execute
tu manually create it?
@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.