feat(fulfillment): Migration backward compatibility (#6672)

**What**
- Update migration for backward compatibility. This does not take into account data migration and table cleanup (@olivermrbl do we have a general tasks for the modules on that subject)?
- Rename fulfillment provider id to provider id
- add integration tests to ensure the migration backward compatibility
- add new module type for the options to be used in the medusa config for example

FIXES CORE-1724
This commit is contained in:
Adrien de Peretti
2024-03-12 13:53:33 +00:00
committed by GitHub
parent e82b4788ec
commit 87e63c024e
17 changed files with 896 additions and 137 deletions
@@ -37,7 +37,7 @@ export async function createFullDataStructure(
const shippingOption = await service.createShippingOptions(
generateCreateShippingOptionsData({
fulfillment_provider_id: providerId,
provider_id: providerId,
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
})
@@ -4,7 +4,7 @@ export function generateCreateShippingOptionsData({
name,
service_zone_id,
shipping_profile_id,
fulfillment_provider_id,
provider_id,
price_type,
rules,
type,
@@ -19,7 +19,7 @@ export function generateCreateShippingOptionsData({
return {
service_zone_id: service_zone_id,
shipping_profile_id: shipping_profile_id,
fulfillment_provider_id: fulfillment_provider_id,
provider_id: provider_id,
type: type ?? {
code: "test-type_" + randomString,
description: "test-description_" + randomString,
@@ -49,7 +49,7 @@ moduleIntegrationTestRunner({
const shippingOption = await service.createShippingOptions(
generateCreateShippingOptionsData({
fulfillment_provider_id: providerId,
provider_id: providerId,
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
})
@@ -97,7 +97,7 @@ moduleIntegrationTestRunner({
const shippingOption = await service.createShippingOptions(
generateCreateShippingOptionsData({
fulfillment_provider_id: providerId,
provider_id: providerId,
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
})
@@ -158,7 +158,7 @@ moduleIntegrationTestRunner({
const shippingOption = await service.createShippingOptions(
generateCreateShippingOptionsData({
fulfillment_provider_id: providerId,
provider_id: providerId,
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
})
@@ -38,7 +38,7 @@ async function list(
relations: [
"service_zones.geo_zones",
"service_zones.shipping_options.shipping_profile",
"service_zones.shipping_options.fulfillment_provider",
"service_zones.shipping_options.provider",
"service_zones.shipping_options.type",
"service_zones.shipping_options.rules",
"service_zones.shipping_options.fulfillments.labels",
@@ -61,7 +61,7 @@ moduleIntegrationTestRunner({
generateCreateShippingOptionsData({
service_zone_id: fulfillmentSet.service_zones[0].id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
rules: [
{
attribute: "test-attribute",
@@ -73,7 +73,7 @@ moduleIntegrationTestRunner({
generateCreateShippingOptionsData({
service_zone_id: fulfillmentSet.service_zones[0].id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
rules: [
{
attribute: "test-attribute",
@@ -118,7 +118,7 @@ moduleIntegrationTestRunner({
generateCreateShippingOptionsData({
service_zone_id: fulfillmentSet.service_zones[0].id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
rules: [
{
attribute: "test-attribute",
@@ -130,7 +130,7 @@ moduleIntegrationTestRunner({
generateCreateShippingOptionsData({
service_zone_id: fulfillmentSet.service_zones[0].id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
rules: [
{
attribute: "test-attribute",
@@ -142,7 +142,7 @@ moduleIntegrationTestRunner({
generateCreateShippingOptionsData({
service_zone_id: fulfillmentSet.service_zones[0].id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
rules: [
{
attribute: "test-attribute",
@@ -221,7 +221,7 @@ moduleIntegrationTestRunner({
generateCreateShippingOptionsData({
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
})
const createdShippingOption = await service.createShippingOptions(
@@ -235,7 +235,7 @@ moduleIntegrationTestRunner({
price_type: createData.price_type,
service_zone_id: createData.service_zone_id,
shipping_profile_id: createData.shipping_profile_id,
fulfillment_provider_id: createData.fulfillment_provider_id,
provider_id: createData.provider_id,
shipping_option_type_id: expect.any(String),
type: expect.objectContaining({
id: expect.any(String),
@@ -274,12 +274,12 @@ moduleIntegrationTestRunner({
generateCreateShippingOptionsData({
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
}),
generateCreateShippingOptionsData({
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
}),
]
@@ -298,7 +298,7 @@ moduleIntegrationTestRunner({
price_type: data_.price_type,
service_zone_id: data_.service_zone_id,
shipping_profile_id: data_.shipping_profile_id,
fulfillment_provider_id: data_.fulfillment_provider_id,
provider_id: data_.provider_id,
shipping_option_type_id: expect.any(String),
type: expect.objectContaining({
id: expect.any(String),
@@ -339,7 +339,7 @@ moduleIntegrationTestRunner({
generateCreateShippingOptionsData({
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
rules: [
{
attribute: "test-attribute",
@@ -378,7 +378,7 @@ moduleIntegrationTestRunner({
const shippingOptionData = generateCreateShippingOptionsData({
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
})
const shippingOption = await service.createShippingOptions(
@@ -391,7 +391,7 @@ moduleIntegrationTestRunner({
price_type: "calculated",
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
type: {
code: "updated-test",
description: "updated-test",
@@ -420,7 +420,7 @@ moduleIntegrationTestRunner({
price_type: updateData.price_type,
service_zone_id: updateData.service_zone_id,
shipping_profile_id: updateData.shipping_profile_id,
fulfillment_provider_id: updateData.fulfillment_provider_id,
provider_id: updateData.provider_id,
shipping_option_type_id: expect.any(String),
type: expect.objectContaining({
id: expect.any(String),
@@ -476,7 +476,7 @@ moduleIntegrationTestRunner({
const shippingOptionData = generateCreateShippingOptionsData({
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
})
const shippingOption = await service.createShippingOptions(
@@ -489,7 +489,7 @@ moduleIntegrationTestRunner({
price_type: "calculated",
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
data: {
amount: 2000,
},
@@ -511,7 +511,7 @@ moduleIntegrationTestRunner({
price_type: updateData.price_type,
service_zone_id: updateData.service_zone_id,
shipping_profile_id: updateData.shipping_profile_id,
fulfillment_provider_id: updateData.fulfillment_provider_id,
provider_id: updateData.provider_id,
shipping_option_type_id: expect.any(String),
type: expect.objectContaining({
id: expect.any(String),
@@ -568,12 +568,12 @@ moduleIntegrationTestRunner({
generateCreateShippingOptionsData({
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
}),
generateCreateShippingOptionsData({
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
}),
]
@@ -588,7 +588,7 @@ moduleIntegrationTestRunner({
price_type: "calculated",
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
type: {
code: "updated-test",
description: "updated-test",
@@ -611,7 +611,7 @@ moduleIntegrationTestRunner({
price_type: "calculated",
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
type: {
code: "updated-test",
description: "updated-test",
@@ -645,7 +645,7 @@ moduleIntegrationTestRunner({
price_type: data_.price_type,
service_zone_id: data_.service_zone_id,
shipping_profile_id: data_.shipping_profile_id,
fulfillment_provider_id: data_.fulfillment_provider_id,
provider_id: data_.provider_id,
shipping_option_type_id: expect.any(String),
type: expect.objectContaining({
id: expect.any(String),
@@ -711,18 +711,13 @@ moduleIntegrationTestRunner({
type: "default",
})
const [fulfillmentProvider] =
await MikroOrmWrapper.forkManager().execute(
"insert into fulfillment_provider (id) values ('sp_jdafwfleiwuonl') returning id"
)
const shippingOptionData = {
id: "sp_jdafwfleiwuonl",
name: "test",
price_type: "flat",
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: fulfillmentProvider.id,
provider_id: providerId,
type: {
code: "test",
description: "test",
@@ -767,7 +762,7 @@ moduleIntegrationTestRunner({
const shippingOptionData = generateCreateShippingOptionsData({
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
})
const shippingOption = await service.createShippingOptions(
@@ -812,7 +807,7 @@ moduleIntegrationTestRunner({
const shippingOptionData = generateCreateShippingOptionsData({
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
})
const shippingOption = await service.createShippingOptions(
@@ -858,17 +853,11 @@ moduleIntegrationTestRunner({
fulfillment_set_id: fulfillmentSet.id,
})
// service provider
const [{ id: providerId }] =
await MikroOrmWrapper.forkManager().execute(
"insert into fulfillment_provider (id) values ('sp_jdafwfleiwuonl') returning id"
)
const shippingOption = await service.createShippingOptions(
generateCreateShippingOptionsData({
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
})
)
@@ -933,7 +922,7 @@ moduleIntegrationTestRunner({
generateCreateShippingOptionsData({
service_zone_id: serviceZone.id,
shipping_profile_id: shippingProfile.id,
fulfillment_provider_id: providerId,
provider_id: providerId,
})
)