-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
feat(tax): soft deletes #6486
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Ignored Deployments
|
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.
Very good, few things to look at, we can discuss if needed 💪
@ManyToOne(() => TaxRegion, { | ||
fieldName: "tax_region_id", | ||
index: taxRegionIdIndexName, | ||
cascade: [Cascade.REMOVE, Cascade.PERSIST], | ||
mapToPk: true, | ||
cascade: [Cascade.REMOVE], |
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.
todo: not sure this cascade should be here, I don't see a region being removed when we remove one of the tax rates
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.
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?
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.
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, { |
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.
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
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.
Nope that's not possible - what needs to be reworked?
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.
in the tax rate rule there is a cascade persist on the tax tate, I believe it should be removed right?
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.
Yep you are right - take a look at the latest changes. wdyt?
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.
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 🚀
9f52a55
to
df0c80d
Compare
What