fix(medusa): Ensure no orphan product option values (#2408)

This commit is contained in:
Philip Korsholm
2022-10-12 12:48:50 +02:00
committed by GitHub
parent 69ef713854
commit bb75a0bc5e
3 changed files with 154 additions and 310 deletions
+3 -1
View File
@@ -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()
+1
View File
@@ -812,6 +812,7 @@ class ProductService extends TransactionBaseService {
const productOption = await productOptionRepo.findOne({
where: { id: optionId, product_id: productId },
relations: ["values"],
})
if (!productOption) {