fix(medusa): remove unique cart on payments to allow canceled payments to exist (#1854)

Fixes CORE-321

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Sebastian Rindom
2022-08-24 14:25:40 +00:00
committed by GitHub
co-authored by Adrien de Peretti Oliver Windall Juhl
parent 5ac7f08e4d
commit 9e0cb12120
4 changed files with 193 additions and 6 deletions
+7 -2
View File
@@ -16,6 +16,8 @@ import { Order } from "./order"
import { Swap } from "./swap"
import { generateEntityId } from "../utils/generate-entity-id"
@Index(["cart_id"], { where: "canceled_at IS NOT NULL" })
@Index("UniquePaymentActive", ["cart_id"], { where: "canceled_at IS NULL", unique: true, })
@Entity()
export class Payment extends BaseEntity {
@Index()
@@ -30,7 +32,7 @@ export class Payment extends BaseEntity {
@Column({ nullable: true })
cart_id: string
@OneToOne(() => Cart)
@ManyToOne(() => Cart)
@JoinColumn({ name: "cart_id" })
cart: Cart
@@ -38,7 +40,10 @@ export class Payment extends BaseEntity {
@Column({ nullable: true })
order_id: string
@ManyToOne(() => Order, (order) => order.payments)
@ManyToOne(
() => Order,
(order) => order.payments
)
@JoinColumn({ name: "order_id" })
order: Order