Is "id" a mandatory field for all tables ?
# orm-help
s
Is "id" a mandatory field for all tables ?
n
@shashank let's continue the conversation in this thread 🙂
no,
id
is not mandatory for all tables. But if you want to use
id
, you have to conform to certain possibilities. Can you share your datamodel?
s
I don't want to use 'id' for all tables .
n
You don't have to.
s
I was generating prisma model from existing postgres model
create table alert_offer ( sale_alert_id bigint not null constraint fkkalfe7keier2t8lv4mpr8dtjr references sale_alert on update restrict on delete restrict, offer_id bigint not null constraint fkeg0evpjnarifhv4cbs339lqn9 references checkoutoffer on update restrict on delete restrict, constraint idx_404828_primary primary key (sale_alert_id, offer_id) ); create index idx_404828_fkeg0evpjnarifhv4cbs339lqn9 on alert_offer (offer_id);
n
I suggest you share a reproducible bug report here, so we can figure out what the problem is: https://github.com/prisma/prisma/issues/new?template=bug_report.md
s
Above model defines the model which is giving the error "Alert_offer ✖️ The required field
id
is missing and has to have the format: id: ID! @unique or id: UUID! @unique or id: Int! @unique."
This the schema created by prisma introspect
@nilan will add to github . But do have a look at schema created by prisma.
👍 1
If I am not wrong I see the reason for failing my model is "fail if a model does not specify an id field at all for a passive connector" in { val schema = """ |type Todo { | title: String |} """.stripMargin val result = SchemaSyntaxValidator(schema, isActive = false).validate val error1 = result.head error1.
type
should equal("Todo") error1.field should equal(Some("id")) error1.description should include( s"The required field
id
is missing and has to have the format: id: ID! @unique or id: UUID! @unique or id: Int! @unique.") }