fix(medusa): Ensure no orphan product option values (#2408)
This commit is contained in:
@@ -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