question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues cross-referencing tables from different schemas using Prisma

See original GitHub issue

Feature request

Is your feature request related to a problem? Please describe.

I am trying to use Supabase together with Prisma. There seems to be a problem cross-referencing tables in different schemas. I have auth.users and public.profiles.

Describe the solution you’d like

I would like to be able to use Prisma to manage Supabase DB, but currently I cannot use Auth schema if it’s referencing any of the tables in the public schema.

Is there are way around this issue?

Additional context

Error message from Prisma CLI:

npx prisma db pull
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma

Introspecting based on datasource defined in prisma/schema.prisma …
Error: P4002
The schema of the introspected database was inconsistent: Illegal cross schema reference from `public.profiles` to `auth.users` in constraint `profiles_id_fkey`. Foreign keys between database schemas are not supported in Prisma. Please follow the GitHub ticket: https://github.com/prisma/prisma/issues/1175

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

13reactions
lumenwritescommented, May 21, 2022

I’m looking to set up the exact same thing, I want to manage my tables using Prisma, but have the auth automatically handled by Supabase, it would be amazing.

According to this thread:

There are a lot of developers using this setup.

But I can’t seem to figure out how, and I can’t find any tutorials or code examples. I’m new to Supabase, and I’d really love it if someone could help me to find a way to set this up correctly.

Did any of you guys find a solution?

10reactions
jondcallahancommented, Aug 2, 2021

For anyone coming here in the future, the page linked by @kiwicopple above no longer contains the needed information but I found it in the git history here https://github.com/supabase/supabase/blob/1315bac01bec4fc70ebc0184b524cd9d890e749d/web/docs/guides/auth.mdx#create-a-publicusers-table

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use Prisma with multiple database schemas
If you have tables with the same name in different database schemas, you will need to map the table names to unique model...
Read more >
[solved] Supabase prisma collision - RedwoodJS Community
When I add migrations to my Supabase project that added a trigger to add public.profile records when auth.user records are created I get ......
Read more >
Introspecting based on datasource defined in prisma/schema ...
The schema of the introspected database was inconsistent: Illegal cross schema reference from public.profiles to auth.users in constraint ...
Read more >
Prisma 4.8.0 Release - GitClear
Additionally, we have started optimizing how the Prisma schema is loaded in Prisma Client. You should notice a considerable improvement when ...
Read more >
Prisma Client Python
The Prisma schema · Data source: Specifies your database connection. In this case we use a local SQLite database however you can also...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found