Skip to content

Commit 2e6b110

Browse files
authored
fix(medusa,pricing): Fix migrations for existing databases (medusajs#5730)
1 parent 5f6751a commit 2e6b110

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

.changeset/rare-apples-sort.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@medusajs/pricing": patch
3+
"@medusajs/medusa": patch
4+
---
5+
6+
fix(medusa,pricing): fix migrations for existing databases

packages/medusa/src/scripts/migrate-to-pricing-module.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ const migratePriceLists = async (container: AwilixContainer) => {
5959

6060
for (const corePriceList of corePriceLists) {
6161
if (priceListIdsToUpdateSet.has(corePriceList.id)) {
62-
priceListsToCreate.push(corePriceList)
63-
} else {
6462
priceListsToUpdate.push(corePriceList)
63+
} else {
64+
priceListsToCreate.push(corePriceList)
6565
}
6666

6767
const corePrices = corePriceList.prices || []
@@ -93,7 +93,6 @@ const migratePriceLists = async (container: AwilixContainer) => {
9393
priceListsToUpdate.map((priceList) => {
9494
const updateData: PricingTypes.UpdatePriceListDTO = {
9595
id: priceList.id,
96-
title: priceList.name,
9796
}
9897

9998
if (priceList?.customer_groups?.length) {

packages/pricing/src/migrations/Migration20231101232834.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class Migration20231101232834 extends Migration {
1717
`ALTER TABLE price_list
1818
ADD COLUMN IF NOT EXISTS number_rules integer not null default 0`
1919
)
20-
20+
2121
this.addSql(
2222
'alter table "price_set_money_amount" drop constraint "price_set_money_amount_price_list_id_foreign";'
2323
)
@@ -35,10 +35,7 @@ export class Migration20231101232834 extends Migration {
3535
SET title = name
3636
`)
3737

38-
this.addSql(`alter table "price_list"
39-
alter column "title" set not null `)
40-
41-
this.addSql('alter table "price_list" drop column if exists "name";')
38+
this.addSql(`alter table "price_list" alter column "title" set not null `)
4239

4340
this.addSql(
4441
'create index if not exists "IDX_price_list_deleted_at" on "price_list" ("deleted_at");'

0 commit comments

Comments
 (0)