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
[Introspection] Cross Schema Foreign Keys #1175
Comments
We don't support cross schema foreign keys. So in that case I think this should be a general feature request. |
I've run into this issue when trying to run It seems that Prisma considers each schema as an independent data source and I suspect that's often not the case - especially for bigger databases. Unfortunately, until this is addressed, it won't be possible to use Prisma in these situations. |
This functionality also exists for SQL Server, not just Postgres: #4762 This also includes a current snapshot of the error message you get on cross schema foreign keys:
|
Ran into the same issue trying to use Prisma with Supabase db. This prevents using Supabase Auth together with Supabase Database. |
Note: This is actually related to #1122 which we are currently looking into, so will hopefully be covered by that as well. Feel free to subscribe to that issue as well for updates. |
This shut down pretty quick any hopes or interest in trying Prisma against our MSSQL database at work. We have a schema for each service in our SOA architecture, which is fairly standard. Would love to see this implemented. |
To query across we need to represent it in the schema, which means we would also need to test these which we usually do using Introspection - so the chance that we do both (and migrating such tables) at the same time is pretty high. |
Same here, unable to use Supabase PostgreSQL DB with Prisma. @edgarasben did you find any workarounds? |
@MonsterDeveloper I ended up using only the |
@edgarasben thanks! Will dig into it. |
@MonsterDeveloper np! If you want to use Supabase Auth, you can use trigger to copy changes from |
Introspection is not part of it, but we shipped a first version of multi schema support in 4.3.0: #1122 (comment) Everyone who is interested in Introspection of multi schema can probably also help us test this first implementation step, so plese go and have a look. |
Any updates on this? We're approaching the end of 2022 :( |
According to the roadmap, it's already in early availability: https://prismaio.notion.site/Prisma-Roadmap-50766227b779464ab98899accb98295f?p=f7107b3ed0194763835c42f0fc54fc8e&pm=s |
The query part is available via |
This would be super useful / necessary to work with https://nhost.io/ (similar to supabase). Hope it's supported soon! |
Can you share exactly why this is specifically important for Nhost? Do they have some default setups across multiple schemas @philefstat? Thanks. |
+1 on this request. We have foreign keys between many of our schemas so cannot swap over until we can begin to use them. I just tried the introspection in 4.7 though, and it's awesome! Great work there :D |
Hey Everyone - we just shipped full support for multiple schemas (and foreign keys between them) for PostgreSQL in 4.7.0 |
Including for migrations? When I run
|
Can you open a new issue @chrskerr and provide more information? Having the schema for example would help a lot so we can reproduce this. (If you can not share publicly, still create the issue but send the schema to schemas@prisma.io [If needed we can also do an NDA].) |
This is absolutely critical towards wider Prisma adoption. There's third party platforms like Hasura that can do cross-schema queries with zero effort. Why has this been stalling for over a year when it's probably one of the most significant obstacles in having developers use it with popular platforms like Supabase (and others)? |
This has been implemented and shipped with 4.7.0 for PostgreSQL behind the |
@janpio On 4.7.1 prisma-client and it is still failing when using it with Supabase trying to reference auth.users, any ideas? |
@chanmathew |
hi @janpio, thanks for the prompt response, I have the flag on in the schema file:
In my Supabase I have However when I run
UPDATE Also side note for others who may run into this issue, Prisma will seem to fail to run Prisma Studio if you happen to have another |
There should be no clashes via |
I can confirm what @chanmathew said,
With the "schemas" it works as intended. |
I call
But when I'm trying to call
|
I tried to reproduce this issue. Copied your data model and tried to run |
@aleksey-mukho Your error message does not look like it's coming from |
We consider this work done as of |
Anyone having issues with
|
Please open a new issue @nahtnam - that should definitely not happen and we would love to debug that with you. Thanks! |
relational.fit.cvut.cz
DB server has 2 schemasctu_crossSchema1
andctu_crossSchema2
that reference each other in foreign keys:Error messages during introspection:
SQL:
The text was updated successfully, but these errors were encountered: