Short answer
Read the Detail line. “is not present in table” is an insert problem, and “is still referenced from table” is a delete problem. On insert, create the parent row first and check the ID you send, such as auth.uid() for a profile. On delete, choose what should happen to the child rows and set it on the foreign key, such as on delete cascade for a profile tied to auth.users. Then run the delete again.
Rather not fix it yourself? App Fix Ticket starts with a fixed-price diagnosis, then a fixed price for the fix before any fix work.
Why the row is refused, and the fix
01
The insert points at a row that doesn’t exist
“A foreign key constraint specifies that the values in a column (or a group of columns) must match the values appearing in some row of another table.” PostgreSQL docs, Constraints (foreign keys)
The ID in the new row has no match in the table it references. Common cases: a profile saved with an ID from another project, a child saved before its parent, or seed data in the wrong order.
02
Deleting a user who still has rows
“Reference the auth.users table to ensure data integrity. Specify on delete cascade in the reference.” Supabase, User management
Without an on delete rule, Postgres refuses to delete a row that other rows reference. For data that belongs to the user, drop the constraint and add it back with on delete cascade. profiles_id_fkey is only the default name, so check the real one in the table’s constraints first.
alter table public.profiles drop constraint profiles_id_fkey, add constraint profiles_id_fkey foreign key (id) references auth.users (id) on delete cascade;03
Pick the right on delete rule
“The default ON DELETE action is ON DELETE NO ACTION; this does not need to be specified.” PostgreSQL docs, Constraints (foreign keys)
Cascade removes the child rows. Set null keeps them with an empty link, for example orders you need to keep for tax records, and needs a column that allows null. The default blocks the delete.
04
The user owns files in Storage
“You cannot delete a user if they are the owner of any objects in Supabase Storage.” Supabase, User management
A user delete can also fail on Storage. Delete or move the user’s files first, then delete the user.
05
Point keys at id to avoid this later
“Only use primary keys as foreign key references for schemas and tables like auth.users which are managed by Supabase.” Supabase, User management
Point foreign keys to auth.users at its id column, not at email or another field that Supabase can update, so rows don’t end up pointing at nothing.
Checked against the vendor’s docs on : PostgreSQL docs: Constraints (foreign keys); Supabase docs: User management.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.See scope and start
“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
Related: Supabase violates not-null constraint · Supabase duplicate key violates unique constraint · Supabase “Database error saving new user” · Supabase operator does not exist: uuid = text