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:
co-authored by
Adrien de Peretti
Oliver Windall Juhl
parent
5ac7f08e4d
commit
9e0cb12120
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user