fix(medusa): Ensure no orphan product option values (#2408)
This commit is contained in:
1 parent
69ef713854
commit
bb75a0bc5e
3 files changed
+154
-310
No files matched your search
@@ -18,7 +18,9 @@ export class ProductOption extends SoftDeletableEntity {
|
||||
@Column()
|
||||
title: string
|
||||
|
||||
@OneToMany(() => ProductOptionValue, (value) => value.option)
|
||||
@OneToMany(() => ProductOptionValue, (value) => value.option, {
|
||||
cascade: ["soft-remove", "remove"],
|
||||
})
|
||||
values: ProductOptionValue[]
|
||||
|
||||
@Column()
|
||||
|
||||
@@ -812,6 +812,7 @@ class ProductService extends TransactionBaseService {
|
||||
|
||||
const productOption = await productOptionRepo.findOne({
|
||||
where: { id: optionId, product_id: productId },
|
||||
relations: ["values"],
|
||||
})
|
||||
|
||||
if (!productOption) {
|
||||
|
||||
Reference in new issue
Block a user