So we were making a microservice in nestJS and usi...
# orm-help
a
So we were making a microservice in nestJS and using prisma for the ORM. Our existing app is on rails so it's default ORM understands that:
user_id
in the table
user_posts
is a reference to the table
users
. So when I introspect the database, schema like the following is generated, where it doesn't implicitly knows the relations
Copy code
model users {
  id               BigInt   @id @default(autoincrement())
  user_name        String?  @db.VarChar
  tenant_id  	   Int?
}

model user_posts {
  id                BigInt    @id @default(autoincrement())
  post_id           Int?
  user_id           Int?
  tenant_id  		Int?
}
Any solution for this other than declaring each supposed foreign key in the main database?
👀 1
r
Hi @Amit Kumar 👋 Only relations between models on the database level will be picked up. This means that there must be a foreign key set.
a
So can I not manually change the schema without migrating the changes to production database?
As in make the changes for the staging/dev db and just deploy the same prisma model in with production DB string?
r
You should be able to make changes to the schema
a
Can you send some documents on how would I be able to automate this. We have more than 100 tables
r
You will need to manually update the schema to define relations between models.
v
👋 Hello @Amit Kumar, were you ultimately able to resolve this or is it still an open issue?