fix(medusa,pricing): Fix migrations for existing databases (#5730)
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/pricing": patch
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa,pricing): fix migrations for existing databases
|
||||||
@@ -59,9 +59,9 @@ const migratePriceLists = async (container: AwilixContainer) => {
|
|||||||
|
|
||||||
for (const corePriceList of corePriceLists) {
|
for (const corePriceList of corePriceLists) {
|
||||||
if (priceListIdsToUpdateSet.has(corePriceList.id)) {
|
if (priceListIdsToUpdateSet.has(corePriceList.id)) {
|
||||||
priceListsToCreate.push(corePriceList)
|
|
||||||
} else {
|
|
||||||
priceListsToUpdate.push(corePriceList)
|
priceListsToUpdate.push(corePriceList)
|
||||||
|
} else {
|
||||||
|
priceListsToCreate.push(corePriceList)
|
||||||
}
|
}
|
||||||
|
|
||||||
const corePrices = corePriceList.prices || []
|
const corePrices = corePriceList.prices || []
|
||||||
@@ -93,7 +93,6 @@ const migratePriceLists = async (container: AwilixContainer) => {
|
|||||||
priceListsToUpdate.map((priceList) => {
|
priceListsToUpdate.map((priceList) => {
|
||||||
const updateData: PricingTypes.UpdatePriceListDTO = {
|
const updateData: PricingTypes.UpdatePriceListDTO = {
|
||||||
id: priceList.id,
|
id: priceList.id,
|
||||||
title: priceList.name,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priceList?.customer_groups?.length) {
|
if (priceList?.customer_groups?.length) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export class Migration20231101232834 extends Migration {
|
|||||||
`ALTER TABLE price_list
|
`ALTER TABLE price_list
|
||||||
ADD COLUMN IF NOT EXISTS number_rules integer not null default 0`
|
ADD COLUMN IF NOT EXISTS number_rules integer not null default 0`
|
||||||
)
|
)
|
||||||
|
|
||||||
this.addSql(
|
this.addSql(
|
||||||
'alter table "price_set_money_amount" drop constraint "price_set_money_amount_price_list_id_foreign";'
|
'alter table "price_set_money_amount" drop constraint "price_set_money_amount_price_list_id_foreign";'
|
||||||
)
|
)
|
||||||
@@ -35,10 +35,7 @@ export class Migration20231101232834 extends Migration {
|
|||||||
SET title = name
|
SET title = name
|
||||||
`)
|
`)
|
||||||
|
|
||||||
this.addSql(`alter table "price_list"
|
this.addSql(`alter table "price_list" alter column "title" set not null `)
|
||||||
alter column "title" set not null `)
|
|
||||||
|
|
||||||
this.addSql('alter table "price_list" drop column if exists "name";')
|
|
||||||
|
|
||||||
this.addSql(
|
this.addSql(
|
||||||
'create index if not exists "IDX_price_list_deleted_at" on "price_list" ("deleted_at");'
|
'create index if not exists "IDX_price_list_deleted_at" on "price_list" ("deleted_at");'
|
||||||
|
|||||||
Reference in New Issue
Block a user