rembrembdocs

Errors

... prepared statement already exists#

Supavisor in transaction mode (port 6543) does not support prepared statements, which Prisma will try to create in the background.

Solution: #

1.../postgres?pgbouncer=true

Can't reach database server at:#

Prisma couldn't establish a connection with Postgres or Supavisor before the timeout

Possible causes: #

Solutions: #

1.../postgres?connect_timeout=30

Timed out fetching a new connection from the connection pool:#

Prisma is unable to allocate connections to pending queries fast enough to meet demand.

Possible causes: #

Solutions: #


Server has closed the connection#

According to this GitHub Issue for Prisma, this error may be related to large return values for queries. It may also be caused by significant database strain.

Solutions: #


Drift detected: Your database schema is not in sync with your migration history#

Prisma relies on migration files to ensure your database aligns with Prisma's model. External schema changes are detected as "drift", which Prisma will try to overwrite, potentially causing data loss.

Possible causes: #

Solution: #


Max client connections reached#

Postgres or Supavisor rejected a request for more connections

Possible causes:#

Solutions #


Cross schema references are only allowed when the target schema is listed in the schemas property of your data-source#

A Prisma migration is referencing a schema it is not permitted to manage.

Possible causes: #

Solutions: #

1generator client {2  provider        = "prisma-client-js"3  previewFeatures = ["multiSchema"]  //Add line4}56datasource db {7  provider  = "postgresql"8  url       = env("DATABASE_URL")9  directUrl = env("DIRECT_URL")10  schemas   = ["public", "other_schema"] //list out relevant schemas11}

An alternative strategy to reference these tables is to duplicate values into Prisma managed table with triggers. Below is an example for duplicating values from auth.users into a table called profiles.

Show/Hide Details

1-- Create the 'profiles' table in the 'public' schema2create table public.profiles (3  id uuid primary key,             -- 'id' is a UUID and the primary key for the table4  email varchar(256)               -- 'email' is a variable character field with a maximum length of 256 characters5);
1-- Function to handle the insertion of a new user into the 'profiles' table2create function public.handle_new_user()3returns trigger4language plpgsql5security definer set search_path = ''6as $$7begin89  -- Insert the new user's data into the 'profiles' table10  insert into public.profiles (id, email)11  values (new.id, new.email);1213  return new;     -- Return the new record14end;15$$;
1-- Function to handle the updating of a user's information in the 'profiles' table2create function public.update_user()3returns trigger4language plpgsql5security definer set search_path = ''6as7$$8begin9  -- Update the user's data in the 'profiles' table10  update public.profiles11  set email = new.email     -- Update the 'email' field12  where id = new.id;        -- Match the 'id' field with the new record1314  return new;  -- Return the new record15end;16$$;
1-- Function to handle the deletion of a user from the 'profiles' table2create function public.delete_user()3returns trigger4language plpgsql5security definer set search_path = ''6as7$$8begin9  -- Delete the user's data from the 'profiles' table10  delete from public.profiles11  where id = old.id;  -- Match the 'id' field with the old record1213  return old;  -- Return the old record14end;15$$;
1-- Trigger to run 'handle_new_user' function after a new user is inserted into 'auth.users' table2create trigger on_auth_user_created3  after insert on auth.users4  for each row execute procedure public.handle_new_user();56-- Trigger to run 'update_user' function after a user is updated in the 'auth.users' table7create trigger on_auth_user_updated8  after update on auth.users9  for each row execute procedure public.update_user();1011-- Trigger to run 'delete_user' function after a user is deleted from the 'auth.users' table12create trigger on_auth_user_deleted13  after delete on auth.users14  for each row execute procedure public.delete_user();