P
Prisma•6mo ago
Llamanat3r

Supabase Database w/ Prisma, not return `slug` column.

Hi, So I have the following model described with Prisma.
model BattleSize {
id Int @id @default(autoincrement())
title String
description String
icon String?
pointsMin Int @default(0)
pointsMax Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
slug String @unique
battles Battle[]
}
model BattleSize {
id Int @id @default(autoincrement())
title String
description String
icon String?
pointsMin Int @default(0)
pointsMax Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
slug String @unique
battles Battle[]
}
My table in Supabase show all the correct columns, and my seed script populated the slug table with unique identifiers. However, when using Prisma, I'm unable to get the slug column back from Supabase.
[
{
"id": 1,
"title": "Combat Patrol",
"description": "The smallest and fastest game size, typically using the contents of a single Combat Patrol box set. It's designed for quick, balanced games that are great for beginners or when you have limited time.",
"icon": null,
"pointsMin": 0,
"pointsMax": 500,
"createdAt": "2025-06-07T03:49:18.204Z",
"updatedAt": "2025-06-07T13:59:15.581Z"
},
...
]
[
{
"id": 1,
"title": "Combat Patrol",
"description": "The smallest and fastest game size, typically using the contents of a single Combat Patrol box set. It's designed for quick, balanced games that are great for beginners or when you have limited time.",
"icon": null,
"pointsMin": 0,
"pointsMax": 500,
"createdAt": "2025-06-07T03:49:18.204Z",
"updatedAt": "2025-06-07T13:59:15.581Z"
},
...
]
Is there something unique with a column named slug? Do I need to interact with the slug column? Things I have tried: - npx prisma db pull - npx prima db push
3 Replies
Prisma AI Help
Prisma AI Help•6mo ago
You selected the bot's instantaneous insights. Let me compile your answer right away! Based on the information in the knowledge sources, there is no indication that Prisma or Supabase treats a column named slug in a special or unique way. The slug column should be handled like any other String column with a @unique constraint. However, there are a few relevant issues and troubleshooting steps to consider: 1. Introspection Issues: There have been cases where Prisma's introspection (prisma db pull) does not pick up unique constraints or even columns under certain circumstances, especially if the database schema and the Prisma schema get out of sync. For example, a unique constraint on slug was not reflected in the Prisma schema after introspection, even though it existed in the database. This was reported as a bug, but the column itself should still appear unless there is a deeper schema mismatch or migration issue Postgres Introspection occasionally removes "Unique" Constraint. 2. Migration Problems: If you have recently added the slug column and made it required (NOT NULL) and unique, but there are existing rows with NULL values or missing the column, migrations can fail or behave unexpectedly. This can result in the column not being properly available to Prisma queries, or Prisma not being able to map it correctly Error P3006 - Null constraint failed. 3. Database Schema Sync: If you have run both prisma db pull and prisma db push and the column still does not appear in your Prisma results, double-check that: - The column exists in the Supabase table and is populated for all rows. - Your Prisma schema matches the actual database schema. - There are no migration errors or warnings about the slug column. 4. No Special Handling for slug: There is no evidence in the knowledge sources that Prisma or Supabase treats the slug column name in a special way. It should work like any other column. Recommendation:
- Double-check your database directly (via Supabase SQL editor) to ensure the slug column exists and is populated. - Make sure your Prisma schema is up to date with prisma db pull. - If the issue persists, try resetting your migrations or re-introspecting the schema. If after all these steps the slug column is still missing from Prisma query results, there may be a deeper issue not covered in the current knowledge sources. In that case, providing more details or error logs would help further diagnose the problem. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Llamanat3r
Llamanat3rOP•6mo ago
Update: I added a column test and I'm getting this error.
Error seeding item with slug warhammer_40k_battle_roles_unassigned: PrismaClientValidationError:
Invalid `prisma.battleRole.upsert()` invocation:

{
where: {
slug: "warhammer_40k_battle_roles_unassigned"
},
update: {
slug: "warhammer_40k_battle_roles_unassigned",
title: "Unassigned",
description: "",
test: "Unassigned Test"
},
create: {
slug: "warhammer_40k_battle_roles_unassigned",
title: "Unassigned",
description: "",
test: "Unassigned Test",
~~~~
? icon?: String | Null,
? createdAt?: DateTime,
? updatedAt?: DateTime
}
}

Unknown argument `test`. Available options are marked with ?.
Error seeding item with slug warhammer_40k_battle_roles_unassigned: PrismaClientValidationError:
Invalid `prisma.battleRole.upsert()` invocation:

{
where: {
slug: "warhammer_40k_battle_roles_unassigned"
},
update: {
slug: "warhammer_40k_battle_roles_unassigned",
title: "Unassigned",
description: "",
test: "Unassigned Test"
},
create: {
slug: "warhammer_40k_battle_roles_unassigned",
title: "Unassigned",
description: "",
test: "Unassigned Test",
~~~~
? icon?: String | Null,
? createdAt?: DateTime,
? updatedAt?: DateTime
}
}

Unknown argument `test`. Available options are marked with ?.
However my database does show that the column test is present.
Nurul
Nurul•6mo ago
Just to confirm: Did you regenerate the PrismaClient with npx prisma generate?

Did you find this page helpful?