Skip to content
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

chore: fix has-one relation migrate #1126

Closed

Conversation

dordieux
Copy link

This is a fix for the PR: #1115.

It fixes a bug where the foreign key was incorrectly created on the table that has a 'has-one' relation.
I also modified the tests slightly to improve clarity.

@bevzzz
Copy link
Collaborator

bevzzz commented Feb 15, 2025

From my understanding, has-one and belongs-to are 2 sides of 1 coin, that is, they are almost synonymous. The choice between them depends wholly on how the user chooses to model their data.

Some may say (following the example from he docs) that "a user has one profile" and some that "this profile belongs to a user"; they will then model their database accordingly. Provided they called .WithForeignKeys(), a foreign key should be created in either case.

Which is why I am not in favor of dropping this functionality for one of these relation types.

@dordieux
Copy link
Author

@bevzzz
Thank you for your review.
As discussed in the original issue, I agree as well.
I'll close this for now and reconsider.
I appreciate your support!

@dordieux dordieux closed this Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants