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

fix: Unique constraint should account for soft deleted records #11048

Merged
merged 8 commits into from
Jan 22, 2025

Conversation

adrien2p
Copy link
Member

@adrien2p adrien2p commented Jan 20, 2025

FIXES FRMW-2878

What
Currently, the one-to-one unique constraints does not account for deleted record. This prevents from inserting a new record wth the same fk if another one is deleted.

Caveat
hasOne with FK option is meant to be a special case, for example a many to one - one to many without defining the other side of the relation. In that case we don't handle this behaviour and keep it as it is

Copy link

changeset-bot bot commented Jan 20, 2025

🦋 Changeset detected

Latest commit: 62d4186

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 65 packages
Name Type
@medusajs/cart Patch
@medusajs/fulfillment Patch
@medusajs/notification Patch
@medusajs/payment Patch
@medusajs/promotion Patch
@medusajs/region Patch
@medusajs/stock-location Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/utils Patch
integration-tests-http Patch
@medusajs/cli Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/file Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/order Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/sales-channel Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/user Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/core-flows Patch
@medusajs/framework Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/types Patch
@medusajs/workflows-sdk Patch
@medusajs/medusa-oas-cli Patch
@medusajs/oas-github-ci Patch
@medusajs/telemetry Patch
@medusajs/admin-bundler Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/dashboard Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
medusa-dev-cli Patch

Not sure what this means? Click here to learn what changesets are.

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

Copy link

vercel bot commented Jan 20, 2025

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

Name Status Preview Comments Updated (UTC)
api-reference 🔄 Building (Inspect) Visit Preview 💬 Add feedback Jan 21, 2025 4:12pm
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 21, 2025 4:12pm
5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference-v2 ⬜️ Ignored (Inspect) Visit Preview Jan 21, 2025 4:12pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Jan 21, 2025 4:12pm
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Jan 21, 2025 4:12pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Jan 21, 2025 4:12pm
resources-docs ⬜️ Ignored (Inspect) Visit Preview Jan 21, 2025 4:12pm

@adrien2p
Copy link
Member Author

@sradevski @olivermrbl wdyt?

Copy link
Member

@sradevski sradevski left a comment

Choose a reason for hiding this comment

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

I think this looks good. I believe this shouldn't have any breaking change consequences, since it is a less strict check right?

@adrien2p
Copy link
Member Author

I think this looks good. I believe this shouldn't have any breaking change consequences, since it is a less strict check right?

Yes that's correct, it is less strict than it was before

@kodiakhq kodiakhq bot merged commit da3906e into develop Jan 22, 2025
23 checks passed
@kodiakhq kodiakhq bot deleted the fix/unique-constraint-definition branch January 22, 2025 07:43
This was referenced Jan 22, 2025
noubase pushed a commit to noubase/medusa that referenced this pull request Jan 22, 2025
…ajs#11048)

FIXES FRMW-2878

**What**
Currently, the `one-to-one` unique constraints does not account for deleted record. This prevents from inserting a new record wth the same fk if another one is deleted.

**Caveat**
`hasOne` with FK option is meant to be a special case, for example a many to one - one to many without defining the other side of the relation. In that case we don't handle this behaviour and keep it as it is
LeroySteding pushed a commit to LeroySteding/medusa-hifive that referenced this pull request Jan 22, 2025
…ajs#11048)

FIXES FRMW-2878

**What**
Currently, the `one-to-one` unique constraints does not account for deleted record. This prevents from inserting a new record wth the same fk if another one is deleted.

**Caveat**
`hasOne` with FK option is meant to be a special case, for example a many to one - one to many without defining the other side of the relation. In that case we don't handle this behaviour and keep it as it is
jimrarras pushed a commit to jimrarras/medusa that referenced this pull request Jan 28, 2025
…ajs#11048)

FIXES FRMW-2878

**What**
Currently, the `one-to-one` unique constraints does not account for deleted record. This prevents from inserting a new record wth the same fk if another one is deleted.

**Caveat**
`hasOne` with FK option is meant to be a special case, for example a many to one - one to many without defining the other side of the relation. In that case we don't handle this behaviour and keep it as it is
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.

3 participants