Skip to content

contract infer emits auth.users @relation navigations without inferring users model #783

@olgen

Description

@olgen

Package and version

  • prisma-next: 0.12.0
  • @prisma-next/postgres: 0.12.0
  • Node: v22.x
  • Package manager: bun 1.3.x
  • OS: macOS (darwin)
  • Source DB: PostgreSQL 15 (local Supabase), FKs from publicauth.users

What happened?

Against Supabase, infer output includes relation navigation fields pointing at a users model that was never inferred (auth schema excluded):

model Accounts {
  id    String @id
  users users  @relation(fields: [id], references: [id], onDelete: Cascade, map: "profiles_id_fkey")
  // ...
}

model AdminNotes {
  authorId String @map("author_id")
  author   users  @relation(fields: [authorId], references: [id], onDelete: Cascade, map: "admin_notes_author_id_fkey")
  // ...
}

There is no model users { … } in the inferred file. contract emit fails on the unresolved relation target.

What did you expect to happen?

Either:

  • Infer auth.users (or a documented stub/surface) when FKs reference it, or
  • Omit relation navigation fields for cross-schema FKs and keep only the scalar FK column

Minimal reproduction

  1. Supabase project where e.g. public.accounts.id FK → auth.users.id
  2. prisma-next contract infer --db $DATABASE_URL scoped to / focused on public
  3. Output contains users @relation lines but no model users

Workaround

Strip lines matching /\susers\??\s+@relation/ before contract emit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions