-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shorter many to many relation names #6917
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/keystonejs/keystone-next-docs/DoBsBFAC3cLzTVEizRryvG1baDRY |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Rebased |
4cc0307
to
49bcd6d
Compare
1782294
to
77a39e9
Compare
I think we have a few paths with this:
The The downside, is we are simply kicking that can down the road. Walking through the I am strongly against the |
abb0365
to
261befd
Compare
261befd
to
3f0228c
Compare
f78118b
to
36ceebe
Compare
@@ -252,7 +252,7 @@ We need to reset the ${credentials.type} database "${credentials.database}" at $ | |||
console.log(`✨ A migration has been created at migrations/${generatedMigrationName}`); | |||
|
|||
let shouldApplyMigration = | |||
migrationCanBeApplied && (await confirmPrompt('Would you like to apply this migration?')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mitchellhamilton I have defaulted this to no
, this should help prevent an unintentional DROP
.
1fa49fe
to
1c9d998
Compare
This comment has been minimized.
This comment has been minimized.
If you were building the DB yourself, most people would name these adjacency tables for the two tables they related. Eg, given Having multiple many-to-many relationships between two lists is going to be pretty rare for most systems but of course, we still need to solve for it in the general case. My "perfect world" solution would look something like this:
This is more work that some other solutions we could use but the upsides are..
|
I think The problem is we have The primary concern for me is that by automatically generating migrations [with this change], without enforcing user consideration, could be an unnecessary foot gun. Maybe I'm too conservative. |
Yeah the current solution is fine – I like that it prevents collisions but I don't love the way it arbitrarily picks the name (ie. depending on which list is left and which is right). Like, for Also, if you're going to give people a way to effect the name of these tables (ie. const relationName = `${leftRel.listKey}_${leftRel.fieldPath}${
useLegacyManyRelationNames ? `_${rightRel.listKey}_${rightRel.fieldPath}` : ''
}`; Why not... const relationName = (leftRel.name || rightRel.name) || `${leftRel.listKey}_${rightRel.listKey}`;
Yeah, this is the more important problem really, I just don't have any helpful opinion on it. |
Co-authored-by: Daniel Cousens <413395+dcousens@users.noreply.github.com>
…com/keystonejs/keystone into shorter-many-to-many-relation-names
Closes #6812
This makes two-sided many to many relationships only include one of the sides in the relation table (which Prisma will then include in the table name with an
_
in front). I've also removed_many
from the end of one-sided many relationships for consistency.