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

feat: add support for defining hasOne with FK #10441

Merged
merged 2 commits into from
Dec 5, 2024
Merged

Conversation

thetutlage
Copy link
Contributor

@thetutlage thetutlage commented Dec 5, 2024

Fixes: FRMW-2825

In this PR we add support for defining hasOne relationship in DML with support for foreign keys. This is added because of the way relationships are defined within our Medusa modules and many of them needs a hasOne with Cascades and FK on the same side.

A good example of this is Cart and Address. The relationship is defined as Cart hasOne Address and the Cart model has the address_id. Also, we want a new address to be created automatically via cascades: ['persist'] setting when defined on a Cart.

Copy link

changeset-bot bot commented Dec 5, 2024

⚠️ No Changeset found

Latest commit: a563494

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Dec 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 8:01am
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Dec 5, 2024 8:01am
api-reference-v2 ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 8:01am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 8:01am
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 8:01am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 8:01am
resources-docs ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 8:01am

Copy link
Member

@adrien2p adrien2p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, lets move with this and see how it goes during the rest of the migration

@thetutlage
Copy link
Contributor Author

@olivermrbl and @shahednasser. We do not want to document this right now, as we might see some breaking changes coming to hasOne with foreign keys as we migrate modules.

@thetutlage thetutlage merged commit 223bcff into develop Dec 5, 2024
23 checks passed
@thetutlage thetutlage deleted the feat/has-one-with-fk branch December 5, 2024 08:45
hirotaka pushed a commit to hirotaka/medusa that referenced this pull request Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants