language-tools
language-tools copied to clipboard
Add a configuration option to disallow automatic field additions
When I save this schema:
model User {
id Int @id
}
model Post {
id Int @id
authorId Int
author User @relation(fields: [authorId], references: [id])
}
it gets corrected to:
model User {
id Int @id
posts Post[]
}
model Post {
id Int @id
authorId Int
author User @relation(fields: [authorId], references: [id])
}
(notice the extra field in the User model)
which is nice, but today while I was updating the schema that I use in Studio's tests (which has a lot of different kinds of relations), it quickly became very annoying to see new fields pop up all over the place. I think this will generally be an issue for all schemas that heavily rely on relations.
I propose we add a configuration option that disallows the extension from makin any changes to the schema exept formatting.
Maybe even formatting. Perhaps we can allow people to selectively enable what changes the extension will make to your schema.
I think this is also a broader discussion since afaik it was the plan to always require both sides of a relation, meaning your schema would be illegal if it didn't have posts as the second relation field. In that sense, prisma format just helps you with the typing you'd have to do anyways. I might be wrong, but this was my latest info.
@nikolasburk That's correct still. What I meant is that we assume anyone who switches this option on knows what they're doing. In my case, I would have added those fields myself eventually, but with different names (instead of the autogenerated names), for example. The schema can still stay invalid and the extension can still render red squiggly lines to make that clear.
Perhaps we should invert what I said and have these options "on" by default and let people turn it "off" when they want.