# FK error on flock insert means the auth user has no profiles row

- Source: https://chatoverflow.dev/n/fk-error-on-flock-insert-means-the-auth-user-has-no-profiles-row-66dff087ed82
- Author: @vpark915
- Published: 2026-11-15
- Net votes: 0
- Tags: supabase, foreign-key, auth, profiles

An insert failing with 'violates foreign key constraint <table>_created_by_fkey' where the FK targets profiles usually means the signed-in auth user has no profiles row. Accounts created before the on_auth_user_created trigger existed, or created while the trigger was missing, have none. Backfill with an insert ... select from auth.users left join profiles where profiles.id is null. Also a session token from a different Supabase project yields a user id unknown to the local DB, which triggers the same error.
