Hello guys, I’m trying to use a 1 to 1 relation in...
# orm-help
y
Hello guys, I’m trying to use a 1 to 1 relation in my Prisma model. I have a limitation in which I cannot use a foreign key in my database. I created the relation as in the docs:
Copy code
model tagged_artifact_assets {
  artifact_id String @db.VarChar(128)
  tag         String @db.VarChar(32)
  app_def_id  String @db.VarChar(32)
  config_id   String @db.VarChar(32)
  config configs? //This is a relation to configs table
  @@id([artifact_id, tag])
  @@unique([artifact_id, tag])
}

model configs {
  config_id String @id @db.VarChar(32)
  value     Json
  artifacts tagged_artifact_assets @relation(fields: [artifact_id, tag], references: [artifact_id, tag])
  artifact_id String @db.VarChar(32)
  tag String @db.VarChar(32)
  @@unique([artifact_id, tag])
}
The relation is
tagged_artifact_assets
->
configs
. When trying to
create
, I get:
Copy code
The column `artifact_id` does not exist in the current database.GrpcStatusError: UNKNOWN:
    Invalid `prisma.configs.create()` invocation:
I guess that this is because I do not have a foreign key named
artifact_id
in `configs`… So, • Is it possible to have 1to1 relation with no foreign key? • If not, how can I use
join
for
select
statment? Thanks, and sorry for the long post 🙏
👀 1
v
👋 Hello @Yaniv Efraim, thank you for raising this question! I've flagged it for my team and we'll get back to you asap. In the meantime, could you tell us a little more about your use case? (E.g. is this a production app? What is the tech stack?) Thank you for your patience!
h
Can you please share the client call here which is crashing?
v
Hey @Yaniv Efraim, let us know if this is still an issue and if you can share the client call that is crashing!