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 prisma errors
What to do?
Command failed with exit code 1: yarn rw prisma migrate dev --name create_data_migrations --create-only
Error: P4002
The schema of the introspected database was inconsistent: Illegal cross schema reference from `public.profile` 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
error Command failed with exit code 1.
$ /Users/ajoslin/Documents/Als/Development/vaxxifi/production-candidates/vaccess/node_modules/.bin/rw prisma migrate dev --name create_data_migrations --create-only
Running Prisma CLI:
yarn prisma migrate dev --name create_data_migrations --create-only --schema "/Users/ajoslin/Documents/Als/Development/vaxxifi/production-candidates/vaccess/api/db/schema.prisma"
Prisma schema loaded from db/schema.prisma
Datasource "DS": PostgreSQL database "postgres", schema "public" at "db.scbqrtiaoyjyyqxuxzjl.supabase.co:5432"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
For this reason I decided to do it all myself instead, in my frontend code. When the signup promise resolves I fire off a “create” mutation to set up everything in my public schema.
@ajoslin103 another option in addition to @Tobbe’s solution (which has the added benefit of making such any data/table in your non-public schema is rather shielded perhaps unwanted queries … like PII such as email or social security number in a user’s profile) is to:
write your joins and run that SQL in a queryRaw
write a SQL view (to simplify the raw query) and run that SQL in a queryRaw