Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate cart module to DML #10385

Merged
merged 21 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
058d24f
refactor: migrate cart module to DML
thetutlage Dec 2, 2024
70d6276
Merge branch 'develop' into feat/cart-dml
thetutlage Dec 2, 2024
99c384a
fix: add missing product_handle column
thetutlage Dec 2, 2024
0862748
Merge branch 'develop' into feat/cart-dml
thetutlage Dec 2, 2024
c3ab06f
refactor: remove dead code
thetutlage Dec 2, 2024
2a8f997
Merge branch 'develop' into feat/cart-dml
thetutlage Dec 2, 2024
2df1a2a
feat: re-generate migrations after implementing checks
thetutlage Dec 2, 2024
fbde7a7
Merge branch 'develop' into feat/cart-dml
thetutlage Dec 4, 2024
a715fba
refactor: define cart -> address relationship via hasOne
thetutlage Dec 4, 2024
408f253
refactor: add support for explicitly unsetting the mappedBy
thetutlage Dec 4, 2024
904828d
feat: allow hasOne relationship to contain foreign key
thetutlage Dec 4, 2024
117920b
refactor: regenerate migrations
thetutlage Dec 4, 2024
af5231a
Merge branch 'develop' into feat/cart-dml
thetutlage Dec 4, 2024
58006bf
Merge branch 'develop' into feat/cart-dml
thetutlage Dec 5, 2024
140478d
Merge branch 'develop' into feat/cart-dml
thetutlage Dec 5, 2024
fed6782
refactor: remove custom setup for hasOne with FK
thetutlage Dec 5, 2024
cb7e785
Merge branch 'develop' into feat/cart-dml
thetutlage Dec 5, 2024
0076bc0
refactor: implement feedback
thetutlage Dec 5, 2024
dc9dfc6
Create sour-cats-sort.md
thetutlage Dec 5, 2024
24d2eb7
Merge branch 'develop' into feat/cart-dml
thetutlage Dec 5, 2024
b83214b
refactor: remove unneeded statements from migrations
thetutlage Dec 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/sour-cats-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/cart": patch
"@medusajs/utils": patch
---

refactor: migrate cart module to DML
1 change: 1 addition & 0 deletions packages/core/utils/src/dml/relations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "./has-many"
export * from "./has-one"
export * from "./many-to-many"
export * from "./nullable"
export * from "./has-one-fk"
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { CreateCartDTO } from "@medusajs/framework/types"
import { CreateCartDTO, InferEntityType } from "@medusajs/framework/types"
import { SqlEntityManager } from "@mikro-orm/postgresql"
import { Cart } from "../../../src/models"
import { defaultCartsData } from "./data"
import { toMikroORMEntity } from "@medusajs/framework/utils"

export * from "./data"

export async function createCarts(
manager: SqlEntityManager,
cartsData: CreateCartDTO[] = defaultCartsData
): Promise<Cart[]> {
const carts: Cart[] = []
): Promise<InferEntityType<typeof Cart>[]> {
const carts: InferEntityType<typeof Cart>[] = []

for (let cartData of cartsData) {
let cart = manager.create(Cart, cartData)
let cart = manager.create(toMikroORMEntity(Cart), cartData)

await manager.persistAndFlush(cart)
}
Expand Down
Loading
Loading