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(tax): soft deletes #6486

Merged
merged 2 commits into from
Feb 26, 2024
Merged

feat(tax): soft deletes #6486

merged 2 commits into from
Feb 26, 2024

Conversation

srindom
Copy link
Collaborator

@srindom srindom commented Feb 23, 2024

What

  • Adds soft deletes

@srindom srindom requested review from a team as code owners February 23, 2024 13:56
Copy link

changeset-bot bot commented Feb 23, 2024

⚠️ No Changeset found

Latest commit: 67ad29d

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 Feb 23, 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 Feb 26, 2024 8:23am
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Feb 26, 2024 8:23am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2024 8:23am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2024 8:23am

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.

Very good, few things to look at, we can discuss if needed 💪

packages/tax/src/models/tax-rate.ts Outdated Show resolved Hide resolved
@ManyToOne(() => TaxRegion, {
fieldName: "tax_region_id",
index: taxRegionIdIndexName,
cascade: [Cascade.REMOVE, Cascade.PERSIST],
mapToPk: true,
cascade: [Cascade.REMOVE],
Copy link
Member

Choose a reason for hiding this comment

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

todo: not sure this cascade should be here, I don't see a region being removed when we remove one of the tax rates

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's the other way around - when we remove a TaxRegion, its associated TaxRates should be removed - that's what this cascade ensures.

I thought about why the "soft-remove" doesn't implement it this way around also?

Copy link
Member

@adrien2p adrien2p Feb 23, 2024

Choose a reason for hiding this comment

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

just found out that those cascade are application level cascade, and since we do not populate the relations and use native delete, the cascade is not performed 🤔 The db level cascade is the onDelete: cascade

tax_region: TaxRegion

@OneToMany(() => TaxRateRule, (rule) => rule.tax_rate)
@OneToMany(() => TaxRateRule, (rule) => rule.tax_rate, {
Copy link
Member

Choose a reason for hiding this comment

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

question: can we create a tax_rate from a rule? if not (which I expect), in that case, the relation needs some rework in the rule model

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope that's not possible - what needs to be reworked?

Copy link
Member

Choose a reason for hiding this comment

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

in the tax rate rule there is a cascade persist on the tax tate, I believe it should be removed right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep you are right - take a look at the latest changes. wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

I would say lets go with that as all the tests are green, though the cascade are set at the application level we might need to revisit some of the relation definition any way. I would say lets re have a look at the details later on am move forward 🚀

packages/tax/src/models/tax-rate.ts Show resolved Hide resolved
packages/tax/src/models/tax-region.ts Outdated Show resolved Hide resolved
packages/tax/src/models/tax-region.ts Show resolved Hide resolved
packages/tax/src/models/tax-region.ts Outdated Show resolved Hide resolved
packages/tax/src/models/tax-region.ts Outdated Show resolved Hide resolved
@srindom srindom changed the base branch from feat/tax-module-management to develop February 25, 2024 21:08
@kodiakhq kodiakhq bot merged commit d983329 into develop Feb 26, 2024
16 of 17 checks passed
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