#"The underlying table does not contain a valid unique identifier and can therefore currently not be"

26 messages · Page 1 of 1 (latest)

naive venture
#

Hi vmathi Prisma requires every model to have a unique identifier. In your case, the trading_post_items_for_sale model doesn't have an id field or any other field marked as @id, which is why Prisma is unable to handle it

wise barn
#

What's my solution? I can't change the db, only read

naive venture
#

To the right field

wise barn
#

So on schema.prisma I'm adding @id then should I run a prisma command?

wise barn
#
/// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by Prisma Client.
model trading_post_items_for_sale {
  sale_id                          Int?    @id @unique(map: "sale_id")
  sold_by_player                   String? @db.VarChar(15)
  item_name                        String? @db.VarChar(250)
  item_id                          Int?
  item_amount_start                Int?
  item_price                       Int?
  item_price_estimate_at_time      Int?
  sold_by_player_session_id        String? @db.VarChar(12)
  sold_by_player_session_state_id  String? @db.VarChar(12)
  has_been_pulled_of_sale_by_owner Int?    @default(0) @db.TinyInt
  pulled_of_sale_time              Int?
  created_at                       Int?

  @@index([sold_by_player], map: "sold_by_player")
  @@ignore
}
naive venture
wise barn
#

Yes

wise barn
#

Then I added the @id field

#

@naive venture See line 17

#

But still not working

#

(After adding the @id field and saving the file I ran npx prisma generate)

#

Maybe I'm missing something here. Like the two tables should be joined, it's relational after all, I'm not sure what the best way to handle this stuff is in prisma

naive venture
#

Is your prisma variable instantiated correctly?

#

Because it says your model is undefined, which should not be right

wise barn
#

model trading_post_items_sold_log works fine for querying

wise barn
# wise barn

I mean it is warning me on line 15 that Prisma can't work with it, and on line 31 it says @@ignore not sure what it means

naive venture
#

Could be a typing error

wise barn
#

Ok how do I solve?

wise barn
#

Any help? :/