diff --git a/.changeset/tricky-olives-battle.md b/.changeset/tricky-olives-battle.md new file mode 100644 index 0000000000..3b8a26bc5d --- /dev/null +++ b/.changeset/tricky-olives-battle.md @@ -0,0 +1,9 @@ +--- +"@medusajs/medusa": patch +"@medusajs/order": patch +"@medusajs/dashboard": patch +"@medusajs/core-flows": patch +"@medusajs/types": patch +--- + +Chore/order custom display diff --git a/integration-tests/modules/__tests__/order/order.spec.ts b/integration-tests/modules/__tests__/order/order.spec.ts index 90fefbe851..02ae4191bb 100644 --- a/integration-tests/modules/__tests__/order/order.spec.ts +++ b/integration-tests/modules/__tests__/order/order.spec.ts @@ -281,6 +281,7 @@ medusaIntegrationTestRunner({ status: "pending", version: 1, display_id: 2, + custom_display_id: null, payment_collections: [], payment_status: "not_paid", region_id: "test_region_id", diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/constants.ts b/packages/admin/dashboard/src/routes/orders/order-detail/constants.ts index 957835287d..79b64f366a 100644 --- a/packages/admin/dashboard/src/routes/orders/order-detail/constants.ts +++ b/packages/admin/dashboard/src/routes/orders/order-detail/constants.ts @@ -5,6 +5,7 @@ const DEFAULT_PROPERTIES = [ "canceled_at", "email", "display_id", + "custom_display_id", "currency_code", "metadata", // --- TOTALS --- diff --git a/packages/admin/dashboard/src/routes/orders/order-list/const.ts b/packages/admin/dashboard/src/routes/orders/order-list/const.ts index 6046bfd5fe..d1dc5896b1 100644 --- a/packages/admin/dashboard/src/routes/orders/order-list/const.ts +++ b/packages/admin/dashboard/src/routes/orders/order-list/const.ts @@ -4,6 +4,7 @@ export const DEFAULT_PROPERTIES = [ "created_at", "email", "display_id", + "custom_display_id", "payment_status", "fulfillment_status", "total", diff --git a/packages/core/core-flows/src/order/workflows/create-fulfillment.ts b/packages/core/core-flows/src/order/workflows/create-fulfillment.ts index 1d1dc21b85..b6f84257ed 100644 --- a/packages/core/core-flows/src/order/workflows/create-fulfillment.ts +++ b/packages/core/core-flows/src/order/workflows/create-fulfillment.ts @@ -400,6 +400,7 @@ export const createOrderFulfillmentWorkflow = createWorkflow( fields: [ "id", "display_id", + "custom_display_id", "status", "customer_id", "customer.*", diff --git a/packages/core/types/src/http/order/common.ts b/packages/core/types/src/http/order/common.ts index eb98c93d7b..f6b7be2510 100644 --- a/packages/core/types/src/http/order/common.ts +++ b/packages/core/types/src/http/order/common.ts @@ -740,6 +740,10 @@ export interface BaseOrder { * The order's display ID. */ display_id?: number + /** + * The order's custom display ID. + */ + custom_display_id?: string /** * The order's status. */ diff --git a/packages/core/types/src/order/common.ts b/packages/core/types/src/order/common.ts index 576fa8b05c..d43d2cb822 100644 --- a/packages/core/types/src/order/common.ts +++ b/packages/core/types/src/order/common.ts @@ -1036,6 +1036,11 @@ export interface OrderDTO { */ display_id: number + /** + * The order's custom display ID. + */ + custom_display_id?: string + /** * The active order change, if any. * diff --git a/packages/medusa/src/api/admin/draft-orders/query-config.ts b/packages/medusa/src/api/admin/draft-orders/query-config.ts index e1ccf6fe8f..7f30ced9bd 100644 --- a/packages/medusa/src/api/admin/draft-orders/query-config.ts +++ b/packages/medusa/src/api/admin/draft-orders/query-config.ts @@ -1,6 +1,7 @@ export const defaultAdminListOrderFields = [ "id", "display_id", + "custom_display_id", "status", "version", "email", @@ -16,6 +17,7 @@ export const defaultAdminListOrderFields = [ export const defaultAdminOrderFields = [ "id", "display_id", + "custom_display_id", "status", "version", "email", diff --git a/packages/medusa/src/api/admin/orders/query-config.ts b/packages/medusa/src/api/admin/orders/query-config.ts index 88cc00a161..6fb4a358bb 100644 --- a/packages/medusa/src/api/admin/orders/query-config.ts +++ b/packages/medusa/src/api/admin/orders/query-config.ts @@ -1,6 +1,7 @@ export const defaultAdminOrderFields = [ "id", "display_id", + "custom_display_id", "status", "version", "summary", diff --git a/packages/medusa/src/api/admin/views/[entity]/columns/helpers.ts b/packages/medusa/src/api/admin/views/[entity]/columns/helpers.ts index 3884e36a28..99b3296e90 100644 --- a/packages/medusa/src/api/admin/views/[entity]/columns/helpers.ts +++ b/packages/medusa/src/api/admin/views/[entity]/columns/helpers.ts @@ -22,14 +22,19 @@ export const getColumnCategory = ( semanticType?: string ): HttpTypes.AdminColumn["category"] => { // Check semantic type first - if (semanticType === "timestamp") return "timestamp" - if (semanticType === "status") return "status" + if (semanticType === "timestamp") { + return "timestamp" + } + if (semanticType === "status") { + return "status" + } // Check field name patterns if ( fieldName.includes("_id") || fieldName === "id" || fieldName.includes("display_id") || + fieldName.includes("custom_display_id") || fieldName === "code" ) { return "identifier" @@ -191,7 +196,7 @@ export const getTypeInfoFromGraphQLType = ( semantic_type: "object", context: "metadata", } - } else if (fieldName === "display_id") { + } else if (fieldName === "display_id" || fieldName === "custom_display_id") { return { data_type: "string", semantic_type: "identifier", @@ -264,6 +269,7 @@ const ADDITIONAL_ENTITY_TYPES: Partial> = { export const DEFAULT_COLUMN_ORDERS: Record> = { orders: { display_id: 100, + custom_display_id: 101, created_at: 200, customer_display: 300, "sales_channel.name": 400, @@ -370,6 +376,10 @@ export const generateEntityColumns = ( directFields.unshift("display_id") } + if (entity === "orders" && !directFields.includes("custom_display_id")) { + directFields.unshift("custom_display_id") + } + const additionalTypes = ADDITIONAL_ENTITY_TYPES[entity as Entities] ?? [] additionalTypes.forEach((typeName) => { @@ -380,11 +390,7 @@ export const generateEntityColumns = ( return } - const additionalFields = graphqlSchemaToFields( - schemaTypeMap, - typeName, - [] - ) + const additionalFields = graphqlSchemaToFields(schemaTypeMap, typeName, []) additionalFields.forEach((fieldName) => { if (directFields.includes(fieldName)) { @@ -460,7 +466,8 @@ export const generateEntityColumns = ( const directColumns = directFields.map((fieldName) => { const displayName = formatFieldName(fieldName) - const fieldDef = entityFields[fieldName] || additionalFieldDefinitions.get(fieldName) + const fieldDef = + entityFields[fieldName] || additionalFieldDefinitions.get(fieldName) const typeInfo = fieldDef ? getTypeInfoFromGraphQLType(fieldDef.type, fieldName) : getTypeInfoFromGraphQLType(null, fieldName) diff --git a/packages/medusa/src/api/store/orders/query-config.ts b/packages/medusa/src/api/store/orders/query-config.ts index e495ecef08..767e0fbd7b 100644 --- a/packages/medusa/src/api/store/orders/query-config.ts +++ b/packages/medusa/src/api/store/orders/query-config.ts @@ -5,6 +5,7 @@ export const defaultStoreOrderFields = [ "status", "summary", "display_id", + "custom_display_id", "total", "currency_code", "metadata", @@ -18,6 +19,7 @@ export const defaultStoreRetrieveOrderFields = [ "summary", "currency_code", "display_id", + "custom_display_id", "region_id", "email", "total", diff --git a/packages/modules/api-key/src/migrations/Migration20251015123842.ts b/packages/modules/api-key/src/migrations/Migration20251015123842.ts index 68a4db1d79..223d5c73b1 100644 --- a/packages/modules/api-key/src/migrations/Migration20251015123842.ts +++ b/packages/modules/api-key/src/migrations/Migration20251015123842.ts @@ -1,15 +1,17 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251015123842 extends Migration { - override async up(): Promise { - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_api_key_revoked_at" ON "api_key" (revoked_at) WHERE deleted_at IS NULL;`); - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_api_key_redacted" ON "api_key" (redacted) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_api_key_revoked_at" ON "api_key" (revoked_at) WHERE deleted_at IS NULL;` + ) + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_api_key_redacted" ON "api_key" (redacted) WHERE deleted_at IS NULL;` + ) } override async down(): Promise { - this.addSql(`drop index if exists "IDX_api_key_revoked_at";`); - this.addSql(`drop index if exists "IDX_api_key_redacted";`); + this.addSql(`drop index if exists "IDX_api_key_revoked_at";`) + this.addSql(`drop index if exists "IDX_api_key_redacted";`) } - } diff --git a/packages/modules/cart/src/migrations/Migration20251017153909.ts b/packages/modules/cart/src/migrations/Migration20251017153909.ts index 28b76cc1d1..66d23958a3 100644 --- a/packages/modules/cart/src/migrations/Migration20251017153909.ts +++ b/packages/modules/cart/src/migrations/Migration20251017153909.ts @@ -1,33 +1,43 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251017153909 extends Migration { - override async up(): Promise { - this.addSql(`drop index if exists "IDX_line_item_cart_id";`); + this.addSql(`drop index if exists "IDX_line_item_cart_id";`) - this.addSql(`drop index if exists "IDX_adjustment_item_id";`); + this.addSql(`drop index if exists "IDX_adjustment_item_id";`) - this.addSql(`drop index if exists "IDX_tax_line_item_id";`); + this.addSql(`drop index if exists "IDX_tax_line_item_id";`) - this.addSql(`drop index if exists "IDX_shipping_method_cart_id";`); + this.addSql(`drop index if exists "IDX_shipping_method_cart_id";`) - this.addSql(`drop index if exists "IDX_adjustment_shipping_method_id";`); + this.addSql(`drop index if exists "IDX_adjustment_shipping_method_id";`) - this.addSql(`drop index if exists "IDX_tax_line_shipping_method_id";`); + this.addSql(`drop index if exists "IDX_tax_line_shipping_method_id";`) } override async down(): Promise { - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_line_item_cart_id" ON "cart_line_item" (cart_id) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_line_item_cart_id" ON "cart_line_item" (cart_id) WHERE deleted_at IS NULL;` + ) - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_adjustment_item_id" ON "cart_line_item_adjustment" (item_id) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_adjustment_item_id" ON "cart_line_item_adjustment" (item_id) WHERE deleted_at IS NULL;` + ) - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_tax_line_item_id" ON "cart_line_item_tax_line" (item_id) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_tax_line_item_id" ON "cart_line_item_tax_line" (item_id) WHERE deleted_at IS NULL;` + ) - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_shipping_method_cart_id" ON "cart_shipping_method" (cart_id) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_shipping_method_cart_id" ON "cart_shipping_method" (cart_id) WHERE deleted_at IS NULL;` + ) - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_adjustment_shipping_method_id" ON "cart_shipping_method_adjustment" (shipping_method_id) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_adjustment_shipping_method_id" ON "cart_shipping_method_adjustment" (shipping_method_id) WHERE deleted_at IS NULL;` + ) - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_tax_line_shipping_method_id" ON "cart_shipping_method_tax_line" (shipping_method_id) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_tax_line_shipping_method_id" ON "cart_shipping_method_tax_line" (shipping_method_id) WHERE deleted_at IS NULL;` + ) } - } diff --git a/packages/modules/customer/src/migrations/Migration20251010130829.ts b/packages/modules/customer/src/migrations/Migration20251010130829.ts index 6302e74c29..52e7a87187 100644 --- a/packages/modules/customer/src/migrations/Migration20251010130829.ts +++ b/packages/modules/customer/src/migrations/Migration20251010130829.ts @@ -1,17 +1,13 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251010130829 extends Migration { - override async up(): Promise { - this.addSql( - 'DROP INDEX IF EXISTS "IDX_customer_group_name";' - ); + this.addSql('DROP INDEX IF EXISTS "IDX_customer_group_name";') } override async down(): Promise { this.addSql( 'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_customer_group_name" ON "customer_group" ("name") WHERE "deleted_at" IS NULL;' - ); + ) } - } diff --git a/packages/modules/inventory/src/migrations/Migration20251010131115.ts b/packages/modules/inventory/src/migrations/Migration20251010131115.ts index 3e61f89610..dab1f07fc3 100644 --- a/packages/modules/inventory/src/migrations/Migration20251010131115.ts +++ b/packages/modules/inventory/src/migrations/Migration20251010131115.ts @@ -1,17 +1,13 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251010131115 extends Migration { - override async up(): Promise { - this.addSql( - 'DROP INDEX IF EXISTS "IDX_inventory_level_item_location";' - ); + this.addSql('DROP INDEX IF EXISTS "IDX_inventory_level_item_location";') } override async down(): Promise { this.addSql( 'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_inventory_level_item_location" ON "inventory_level" (inventory_item_id, location_id) WHERE deleted_at IS NULL;' - ); + ) } - } diff --git a/packages/modules/notification/src/migrations/Migration20251028172715.ts b/packages/modules/notification/src/migrations/Migration20251028172715.ts index 62ae337758..748f9658bc 100644 --- a/packages/modules/notification/src/migrations/Migration20251028172715.ts +++ b/packages/modules/notification/src/migrations/Migration20251028172715.ts @@ -1,15 +1,21 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251028172715 extends Migration { - override async up(): Promise { - this.addSql(`alter table if exists "notification" alter column "template" type text using ("template"::text);`); - this.addSql(`alter table if exists "notification" alter column "template" drop not null;`); + this.addSql( + `alter table if exists "notification" alter column "template" type text using ("template"::text);` + ) + this.addSql( + `alter table if exists "notification" alter column "template" drop not null;` + ) } override async down(): Promise { - this.addSql(`alter table if exists "notification" alter column "template" type text using ("template"::text);`); - this.addSql(`alter table if exists "notification" alter column "template" set not null;`); + this.addSql( + `alter table if exists "notification" alter column "template" type text using ("template"::text);` + ) + this.addSql( + `alter table if exists "notification" alter column "template" set not null;` + ) } - } diff --git a/packages/modules/order/integration-tests/__tests__/create-order.spec.ts b/packages/modules/order/integration-tests/__tests__/create-order.spec.ts index 3440440130..a0b48a90e1 100644 --- a/packages/modules/order/integration-tests/__tests__/create-order.spec.ts +++ b/packages/modules/order/integration-tests/__tests__/create-order.spec.ts @@ -6,6 +6,11 @@ jest.setTimeout(100000) moduleIntegrationTestRunner({ moduleName: Modules.ORDER, + moduleOptions: { + generateCustomDisplayId: async (order: CreateOrderDTO): Promise => { + return order.currency_code + "_1234567890" + }, + }, testSuite: ({ service, MikroOrmWrapper }) => { describe("Order Module Service", () => { const input = { @@ -124,6 +129,7 @@ moduleIntegrationTestRunner({ id: expect.stringContaining("order_"), version: 1, display_id: 1, + custom_display_id: "usd_1234567890", summary: expect.objectContaining({ // TODO: add all summary fields }), @@ -413,6 +419,7 @@ moduleIntegrationTestRunner({ "id", "display_id", "version", + "custom_display_id", "items.id", "summary", "items.quantity", diff --git a/packages/modules/order/src/migrations/.snapshot-medusa-order.json b/packages/modules/order/src/migrations/.snapshot-medusa-order.json index 8e9f91fb90..7efe233a3e 100644 --- a/packages/modules/order/src/migrations/.snapshot-medusa-order.json +++ b/packages/modules/order/src/migrations/.snapshot-medusa-order.json @@ -166,7 +166,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_address_deleted_at\" ON \"order_address\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_address_deleted_at\" ON \"order_address\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_address_customer_id", @@ -175,7 +175,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_address_customer_id\" ON \"order_address\" (customer_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_address_customer_id\" ON \"order_address\" (\"customer_id\") WHERE deleted_at IS NULL" }, { "keyName": "order_address_pkey", @@ -212,6 +212,15 @@ "nullable": false, "mappedType": "integer" }, + "custom_display_id": { + "name": "custom_display_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, "region_id": { "name": "region_id", "type": "text", @@ -384,7 +393,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_deleted_at\" ON \"order\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_deleted_at\" ON \"order\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_display_id", @@ -393,7 +402,16 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_display_id\" ON \"order\" (display_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_display_id\" ON \"order\" (\"display_id\") WHERE deleted_at IS NULL" + }, + { + "keyName": "IDX_order_custom_display_id", + "columnNames": [], + "composite": false, + "constraint": false, + "primary": false, + "unique": false, + "expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_order_custom_display_id\" ON \"order\" (\"custom_display_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_region_id", @@ -402,7 +420,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_region_id\" ON \"order\" (region_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_region_id\" ON \"order\" (\"region_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_customer_id", @@ -411,7 +429,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_customer_id\" ON \"order\" (customer_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_customer_id\" ON \"order\" (\"customer_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_sales_channel_id", @@ -420,7 +438,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_sales_channel_id\" ON \"order\" (sales_channel_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_sales_channel_id\" ON \"order\" (\"sales_channel_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_deleted_at", @@ -429,7 +447,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_deleted_at\" ON \"order\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_deleted_at\" ON \"order\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_currency_code", @@ -438,7 +456,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_currency_code\" ON \"order\" (currency_code) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_currency_code\" ON \"order\" (\"currency_code\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_address_id", @@ -447,7 +465,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_address_id\" ON \"order\" (shipping_address_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_address_id\" ON \"order\" (\"shipping_address_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_billing_address_id", @@ -456,7 +474,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_billing_address_id\" ON \"order\" (billing_address_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_billing_address_id\" ON \"order\" (\"billing_address_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_is_draft_order", @@ -465,7 +483,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_is_draft_order\" ON \"order\" (is_draft_order) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_is_draft_order\" ON \"order\" (\"is_draft_order\") WHERE deleted_at IS NULL" }, { "keyName": "order_pkey", @@ -490,7 +508,6 @@ "id" ], "referencedTableName": "public.order_address", - "createForeignKeyConstraint": true, "deleteRule": "set null", "updateRule": "cascade" }, @@ -504,7 +521,6 @@ "id" ], "referencedTableName": "public.order_address", - "createForeignKeyConstraint": true, "deleteRule": "set null", "updateRule": "cascade" } @@ -757,7 +773,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id\" ON \"order_change\" (order_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id\" ON \"order_change\" (\"order_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_change_deleted_at", @@ -766,7 +782,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_deleted_at\" ON \"order_change\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_deleted_at\" ON \"order_change\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_change_return_id", @@ -775,7 +791,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_return_id\" ON \"order_change\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_return_id\" ON \"order_change\" (\"return_id\") WHERE return_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_order_change_claim_id", @@ -784,7 +800,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_claim_id\" ON \"order_change\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_claim_id\" ON \"order_change\" (\"claim_id\") WHERE claim_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_order_change_exchange_id", @@ -793,7 +809,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_exchange_id\" ON \"order_change\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_exchange_id\" ON \"order_change\" (\"exchange_id\") WHERE exchange_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_order_change_status", @@ -802,7 +818,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_status\" ON \"order_change\" (status) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_status\" ON \"order_change\" (\"status\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_change_deleted_at", @@ -811,7 +827,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_deleted_at\" ON \"order_change\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_deleted_at\" ON \"order_change\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_change_version", @@ -820,7 +836,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_version\" ON \"order_change\" (order_id, version) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_version\" ON \"order_change\" (\"order_id\", \"version\") WHERE deleted_at IS NULL" }, { "keyName": "order_change_pkey", @@ -845,7 +861,6 @@ "id" ], "referencedTableName": "public.order", - "createForeignKeyConstraint": true, "updateRule": "cascade" } }, @@ -1042,7 +1057,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_change_id\" ON \"order_change_action\" (order_change_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_change_id\" ON \"order_change_action\" (\"order_change_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_change_action_deleted_at", @@ -1051,7 +1066,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_deleted_at\" ON \"order_change_action\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_deleted_at\" ON \"order_change_action\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_change_action_order_id", @@ -1060,7 +1075,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_id\" ON \"order_change_action\" (order_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_id\" ON \"order_change_action\" (\"order_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_change_action_return_id", @@ -1069,7 +1084,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_return_id\" ON \"order_change_action\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_return_id\" ON \"order_change_action\" (\"return_id\") WHERE return_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_order_change_action_claim_id", @@ -1078,7 +1093,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_claim_id\" ON \"order_change_action\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_claim_id\" ON \"order_change_action\" (\"claim_id\") WHERE claim_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_order_change_action_exchange_id", @@ -1087,7 +1102,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_exchange_id\" ON \"order_change_action\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_exchange_id\" ON \"order_change_action\" (\"exchange_id\") WHERE exchange_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_order_change_action_deleted_at", @@ -1096,7 +1111,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_deleted_at\" ON \"order_change_action\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_deleted_at\" ON \"order_change_action\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_change_action_ordering", @@ -1105,7 +1120,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_ordering\" ON \"order_change_action\" (ordering) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_ordering\" ON \"order_change_action\" (\"ordering\") WHERE deleted_at IS NULL" }, { "keyName": "order_change_action_pkey", @@ -1130,7 +1145,6 @@ "id" ], "referencedTableName": "public.order_change", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" } @@ -1255,7 +1269,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_order_id\" ON \"order_credit_line\" (order_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_order_id\" ON \"order_credit_line\" (\"order_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_credit_line_deleted_at", @@ -1264,7 +1278,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_deleted_at\" ON \"order_credit_line\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_deleted_at\" ON \"order_credit_line\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_credit_line_order_id_version", @@ -1273,7 +1287,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_order_id_version\" ON \"order_credit_line\" (order_id, version) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_order_id_version\" ON \"order_credit_line\" (\"order_id\", \"version\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_credit_line_deleted_at", @@ -1282,7 +1296,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_deleted_at\" ON \"order_credit_line\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_credit_line_deleted_at\" ON \"order_credit_line\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "order_credit_line_pkey", @@ -1307,7 +1321,6 @@ "id" ], "referencedTableName": "public.order", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" } @@ -1607,7 +1620,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_deleted_at\" ON \"order_line_item\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_deleted_at\" ON \"order_line_item\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_line_item_deleted_at", @@ -1616,7 +1629,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_deleted_at\" ON \"order_line_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_deleted_at\" ON \"order_line_item\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_line_item_product_id", @@ -1625,7 +1638,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_product_id\" ON \"order_line_item\" (product_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_product_id\" ON \"order_line_item\" (\"product_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_line_item_product_type_id", @@ -1634,7 +1647,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_line_item_product_type_id\" ON \"order_line_item\" (product_type_id) WHERE deleted_at IS NULL AND product_type_id IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_line_item_product_type_id\" ON \"order_line_item\" (\"product_type_id\") WHERE deleted_at IS NULL AND product_type_id IS NOT NULL" }, { "keyName": "IDX_order_line_item_variant_id", @@ -1643,7 +1656,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_variant_id\" ON \"order_line_item\" (variant_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_variant_id\" ON \"order_line_item\" (\"variant_id\") WHERE deleted_at IS NULL" }, { "keyName": "order_line_item_pkey", @@ -1839,6 +1852,7 @@ "autoincrement": false, "primary": false, "nullable": false, + "default": "'{\"value\":\"0\",\"precision\":20}'", "mappedType": "json" }, "raw_delivered_quantity": { @@ -1848,6 +1862,7 @@ "autoincrement": false, "primary": false, "nullable": false, + "default": "'{\"value\":\"0\",\"precision\":20}'", "mappedType": "json" }, "raw_shipped_quantity": { @@ -1857,6 +1872,7 @@ "autoincrement": false, "primary": false, "nullable": false, + "default": "'{\"value\":\"0\",\"precision\":20}'", "mappedType": "json" }, "raw_return_requested_quantity": { @@ -1866,6 +1882,7 @@ "autoincrement": false, "primary": false, "nullable": false, + "default": "'{\"value\":\"0\",\"precision\":20}'", "mappedType": "json" }, "raw_return_received_quantity": { @@ -1875,6 +1892,7 @@ "autoincrement": false, "primary": false, "nullable": false, + "default": "'{\"value\":\"0\",\"precision\":20}'", "mappedType": "json" }, "raw_return_dismissed_quantity": { @@ -1884,6 +1902,7 @@ "autoincrement": false, "primary": false, "nullable": false, + "default": "'{\"value\":\"0\",\"precision\":20}'", "mappedType": "json" }, "raw_written_off_quantity": { @@ -1893,6 +1912,7 @@ "autoincrement": false, "primary": false, "nullable": false, + "default": "'{\"value\":\"0\",\"precision\":20}'", "mappedType": "json" }, "created_at": { @@ -1938,7 +1958,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_order_id\" ON \"order_item\" (order_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_order_id\" ON \"order_item\" (\"order_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_item_deleted_at", @@ -1947,7 +1967,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_deleted_at\" ON \"order_item\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_deleted_at\" ON \"order_item\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_item_order_id_version", @@ -1956,7 +1976,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_order_id_version\" ON \"order_item\" (order_id, version) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_order_id_version\" ON \"order_item\" (\"order_id\", \"version\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_item_item_id", @@ -1965,7 +1985,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_item_id\" ON \"order_item\" (item_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_item_id\" ON \"order_item\" (\"item_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_item_deleted_at", @@ -1974,7 +1994,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_deleted_at\" ON \"order_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_deleted_at\" ON \"order_item\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "order_item_pkey", @@ -1999,7 +2019,6 @@ "id" ], "referencedTableName": "public.order", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" }, @@ -2013,7 +2032,6 @@ "id" ], "referencedTableName": "public.order_line_item", - "createForeignKeyConstraint": true, "updateRule": "cascade" } }, @@ -2146,7 +2164,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_adjustment_item_id\" ON \"order_line_item_adjustment\" (item_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_adjustment_item_id\" ON \"order_line_item_adjustment\" (\"item_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_line_item_adjustment_deleted_at", @@ -2155,7 +2173,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_adjustment_deleted_at\" ON \"order_line_item_adjustment\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_adjustment_deleted_at\" ON \"order_line_item_adjustment\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_order_line_item_adjustment_item_id", @@ -2164,7 +2182,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_order_line_item_adjustment_item_id\" ON \"order_line_item_adjustment\" (item_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_order_line_item_adjustment_item_id\" ON \"order_line_item_adjustment\" (\"item_id\") WHERE deleted_at IS NULL" }, { "keyName": "order_line_item_adjustment_pkey", @@ -2189,7 +2207,6 @@ "id" ], "referencedTableName": "public.order_line_item", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" } @@ -2313,7 +2330,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_tax_line_item_id\" ON \"order_line_item_tax_line\" (item_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_tax_line_item_id\" ON \"order_line_item_tax_line\" (\"item_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_line_item_tax_line_deleted_at", @@ -2322,7 +2339,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_tax_line_deleted_at\" ON \"order_line_item_tax_line\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_tax_line_deleted_at\" ON \"order_line_item_tax_line\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "order_line_item_tax_line_pkey", @@ -2347,7 +2364,6 @@ "id" ], "referencedTableName": "public.order_line_item", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" } @@ -2491,7 +2507,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_deleted_at\" ON \"order_shipping_method\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_deleted_at\" ON \"order_shipping_method\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_method_shipping_option_id", @@ -2500,7 +2516,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_shipping_option_id\" ON \"order_shipping_method\" (shipping_option_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_shipping_option_id\" ON \"order_shipping_method\" (\"shipping_option_id\") WHERE deleted_at IS NULL" }, { "keyName": "order_shipping_method_pkey", @@ -2634,7 +2650,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_adjustment_shipping_method_id\" ON \"order_shipping_method_adjustment\" (shipping_method_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_adjustment_shipping_method_id\" ON \"order_shipping_method_adjustment\" (\"shipping_method_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_method_adjustment_deleted_at", @@ -2643,7 +2659,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_adjustment_deleted_at\" ON \"order_shipping_method_adjustment\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_adjustment_deleted_at\" ON \"order_shipping_method_adjustment\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "order_shipping_method_adjustment_pkey", @@ -2668,7 +2684,6 @@ "id" ], "referencedTableName": "public.order_shipping_method", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" } @@ -2792,7 +2807,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_tax_line_shipping_method_id\" ON \"order_shipping_method_tax_line\" (shipping_method_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_tax_line_shipping_method_id\" ON \"order_shipping_method_tax_line\" (\"shipping_method_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_method_tax_line_deleted_at", @@ -2801,7 +2816,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_tax_line_deleted_at\" ON \"order_shipping_method_tax_line\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_tax_line_deleted_at\" ON \"order_shipping_method_tax_line\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "order_shipping_method_tax_line_pkey", @@ -2826,7 +2841,6 @@ "id" ], "referencedTableName": "public.order_shipping_method", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" } @@ -2915,7 +2929,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_order_id\" ON \"order_summary\" (order_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_order_id\" ON \"order_summary\" (\"order_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_summary_deleted_at", @@ -2924,7 +2938,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_deleted_at\" ON \"order_summary\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_deleted_at\" ON \"order_summary\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_summary_order_id_version", @@ -2933,7 +2947,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_order_id_version\" ON \"order_summary\" (order_id, version) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_order_id_version\" ON \"order_summary\" (\"order_id\", \"version\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_summary_deleted_at", @@ -2942,7 +2956,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_deleted_at\" ON \"order_summary\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_summary_deleted_at\" ON \"order_summary\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "order_summary_pkey", @@ -2967,7 +2981,6 @@ "id" ], "referencedTableName": "public.order", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" } @@ -3174,7 +3187,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_order_id\" ON \"return\" (order_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_order_id\" ON \"return\" (\"order_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_return_deleted_at", @@ -3183,7 +3196,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_deleted_at\" ON \"return\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_deleted_at\" ON \"return\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_return_display_id", @@ -3192,7 +3205,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_display_id\" ON \"return\" (display_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_display_id\" ON \"return\" (\"display_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_return_deleted_at", @@ -3201,7 +3214,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_deleted_at\" ON \"return\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_deleted_at\" ON \"return\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_return_exchange_id", @@ -3210,7 +3223,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_exchange_id\" ON \"return\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_exchange_id\" ON \"return\" (\"exchange_id\") WHERE exchange_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_return_claim_id", @@ -3219,7 +3232,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_claim_id\" ON \"return\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_claim_id\" ON \"return\" (\"claim_id\") WHERE claim_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "return_pkey", @@ -3244,7 +3257,6 @@ "id" ], "referencedTableName": "public.order", - "createForeignKeyConstraint": true, "updateRule": "cascade" }, "return_exchange_id_foreign": { @@ -3257,7 +3269,6 @@ "id" ], "referencedTableName": "public.order_exchange", - "createForeignKeyConstraint": true, "deleteRule": "set null", "updateRule": "cascade" }, @@ -3271,7 +3282,6 @@ "id" ], "referencedTableName": "public.order_claim", - "createForeignKeyConstraint": true, "deleteRule": "set null", "updateRule": "cascade" } @@ -3433,7 +3443,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_deleted_at\" ON \"order_exchange\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_deleted_at\" ON \"order_exchange\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_exchange_display_id", @@ -3442,7 +3452,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_display_id\" ON \"order_exchange\" (display_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_display_id\" ON \"order_exchange\" (\"display_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_exchange_deleted_at", @@ -3451,7 +3461,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_deleted_at\" ON \"order_exchange\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_deleted_at\" ON \"order_exchange\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_exchange_order_id", @@ -3460,7 +3470,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_order_id\" ON \"order_exchange\" (order_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_order_id\" ON \"order_exchange\" (\"order_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_exchange_return_id", @@ -3469,7 +3479,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_return_id\" ON \"order_exchange\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_return_id\" ON \"order_exchange\" (\"return_id\") WHERE return_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "order_exchange_pkey", @@ -3494,7 +3504,6 @@ "id" ], "referencedTableName": "public.order", - "createForeignKeyConstraint": true, "updateRule": "cascade" }, "order_exchange_return_id_foreign": { @@ -3507,7 +3516,6 @@ "id" ], "referencedTableName": "public.return", - "createForeignKeyConstraint": true, "deleteRule": "set null", "updateRule": "cascade" } @@ -3622,7 +3630,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_exchange_id\" ON \"order_exchange_item\" (exchange_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_exchange_id\" ON \"order_exchange_item\" (\"exchange_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_exchange_item_item_id", @@ -3631,7 +3639,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_item_id\" ON \"order_exchange_item\" (item_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_item_id\" ON \"order_exchange_item\" (\"item_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_exchange_item_deleted_at", @@ -3640,7 +3648,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_deleted_at\" ON \"order_exchange_item\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_deleted_at\" ON \"order_exchange_item\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_exchange_item_deleted_at", @@ -3649,7 +3657,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_deleted_at\" ON \"order_exchange_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_exchange_item_deleted_at\" ON \"order_exchange_item\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "order_exchange_item_pkey", @@ -3674,7 +3682,6 @@ "id" ], "referencedTableName": "public.order_exchange", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" }, @@ -3688,7 +3695,6 @@ "id" ], "referencedTableName": "public.order_line_item", - "createForeignKeyConstraint": true, "updateRule": "cascade" } }, @@ -3852,7 +3858,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_deleted_at\" ON \"order_claim\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_deleted_at\" ON \"order_claim\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_claim_display_id", @@ -3861,7 +3867,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_display_id\" ON \"order_claim\" (display_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_display_id\" ON \"order_claim\" (\"display_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_claim_deleted_at", @@ -3870,7 +3876,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_deleted_at\" ON \"order_claim\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_deleted_at\" ON \"order_claim\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_claim_order_id", @@ -3879,7 +3885,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_order_id\" ON \"order_claim\" (order_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_order_id\" ON \"order_claim\" (\"order_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_claim_return_id", @@ -3888,7 +3894,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_return_id\" ON \"order_claim\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_return_id\" ON \"order_claim\" (\"return_id\") WHERE return_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "order_claim_pkey", @@ -3913,7 +3919,6 @@ "id" ], "referencedTableName": "public.order", - "createForeignKeyConstraint": true, "updateRule": "cascade" }, "order_claim_return_id_foreign": { @@ -3926,7 +3931,6 @@ "id" ], "referencedTableName": "public.return", - "createForeignKeyConstraint": true, "deleteRule": "set null", "updateRule": "cascade" } @@ -4078,7 +4082,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id\" ON \"order_transaction\" (order_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id\" ON \"order_transaction\" (\"order_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_transaction_return_id", @@ -4087,7 +4091,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_return_id\" ON \"order_transaction\" (return_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_return_id\" ON \"order_transaction\" (\"return_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_transaction_exchange_id", @@ -4096,7 +4100,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_exchange_id\" ON \"order_transaction\" (exchange_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_exchange_id\" ON \"order_transaction\" (\"exchange_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_transaction_claim_id", @@ -4105,7 +4109,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_claim_id\" ON \"order_transaction\" (claim_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_claim_id\" ON \"order_transaction\" (\"claim_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_transaction_deleted_at", @@ -4114,7 +4118,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_deleted_at\" ON \"order_transaction\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_deleted_at\" ON \"order_transaction\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_transaction_reference_id", @@ -4123,7 +4127,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_reference_id\" ON \"order_transaction\" (reference_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_reference_id\" ON \"order_transaction\" (\"reference_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_transaction_return_id", @@ -4132,7 +4136,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_return_id\" ON \"order_transaction\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_return_id\" ON \"order_transaction\" (\"return_id\") WHERE return_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_order_transaction_exchange_id", @@ -4141,7 +4145,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_exchange_id\" ON \"order_transaction\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_exchange_id\" ON \"order_transaction\" (\"exchange_id\") WHERE exchange_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_order_transaction_claim_id", @@ -4150,7 +4154,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_claim_id\" ON \"order_transaction\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_claim_id\" ON \"order_transaction\" (\"claim_id\") WHERE claim_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_order_transaction_currency_code", @@ -4159,7 +4163,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_currency_code\" ON \"order_transaction\" (currency_code) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_currency_code\" ON \"order_transaction\" (\"currency_code\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_transaction_deleted_at", @@ -4168,7 +4172,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_deleted_at\" ON \"order_transaction\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_deleted_at\" ON \"order_transaction\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_transaction_order_id_version", @@ -4177,7 +4181,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id_version\" ON \"order_transaction\" (order_id, version) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id_version\" ON \"order_transaction\" (\"order_id\", \"version\") WHERE deleted_at IS NULL" }, { "keyName": "order_transaction_pkey", @@ -4202,7 +4206,6 @@ "id" ], "referencedTableName": "public.order", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" }, @@ -4216,7 +4219,6 @@ "id" ], "referencedTableName": "public.return", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" }, @@ -4230,7 +4232,6 @@ "id" ], "referencedTableName": "public.order_exchange", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" }, @@ -4244,7 +4245,6 @@ "id" ], "referencedTableName": "public.order_claim", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" } @@ -4360,7 +4360,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_order_id\" ON \"order_shipping\" (order_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_order_id\" ON \"order_shipping\" (\"order_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_return_id", @@ -4369,7 +4369,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_return_id\" ON \"order_shipping\" (return_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_return_id\" ON \"order_shipping\" (\"return_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_exchange_id", @@ -4378,7 +4378,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_exchange_id\" ON \"order_shipping\" (exchange_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_exchange_id\" ON \"order_shipping\" (\"exchange_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_claim_id", @@ -4387,7 +4387,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_claim_id\" ON \"order_shipping\" (claim_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_claim_id\" ON \"order_shipping\" (\"claim_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_deleted_at", @@ -4396,7 +4396,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_deleted_at\" ON \"order_shipping\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_deleted_at\" ON \"order_shipping\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_return_id", @@ -4405,7 +4405,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_return_id\" ON \"order_shipping\" (return_id) WHERE return_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_return_id\" ON \"order_shipping\" (\"return_id\") WHERE return_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_exchange_id", @@ -4414,7 +4414,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_exchange_id\" ON \"order_shipping\" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_exchange_id\" ON \"order_shipping\" (\"exchange_id\") WHERE exchange_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_claim_id", @@ -4423,7 +4423,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_claim_id\" ON \"order_shipping\" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_claim_id\" ON \"order_shipping\" (\"claim_id\") WHERE claim_id IS NOT NULL AND deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_order_id_version", @@ -4432,7 +4432,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_order_id_version\" ON \"order_shipping\" (order_id, version) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_order_id_version\" ON \"order_shipping\" (\"order_id\", \"version\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_shipping_method_id", @@ -4441,7 +4441,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_shipping_method_id\" ON \"order_shipping\" (shipping_method_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_shipping_method_id\" ON \"order_shipping\" (\"shipping_method_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_shipping_deleted_at", @@ -4450,7 +4450,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_deleted_at\" ON \"order_shipping\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_deleted_at\" ON \"order_shipping\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "order_shipping_pkey", @@ -4475,7 +4475,6 @@ "id" ], "referencedTableName": "public.order", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" }, @@ -4489,7 +4488,6 @@ "id" ], "referencedTableName": "public.return", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" }, @@ -4503,7 +4501,6 @@ "id" ], "referencedTableName": "public.order_exchange", - "createForeignKeyConstraint": true, "deleteRule": "set null", "updateRule": "cascade" }, @@ -4517,7 +4514,6 @@ "id" ], "referencedTableName": "public.order_claim", - "createForeignKeyConstraint": true, "deleteRule": "set null", "updateRule": "cascade" }, @@ -4531,7 +4527,6 @@ "id" ], "referencedTableName": "public.order_shipping_method", - "createForeignKeyConstraint": true, "updateRule": "cascade" } }, @@ -4670,7 +4665,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_claim_id\" ON \"order_claim_item\" (claim_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_claim_id\" ON \"order_claim_item\" (\"claim_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_claim_item_item_id", @@ -4679,7 +4674,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_item_id\" ON \"order_claim_item\" (item_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_item_id\" ON \"order_claim_item\" (\"item_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_claim_item_deleted_at", @@ -4688,7 +4683,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_deleted_at\" ON \"order_claim_item\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_deleted_at\" ON \"order_claim_item\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_claim_item_deleted_at", @@ -4697,7 +4692,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_deleted_at\" ON \"order_claim_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_deleted_at\" ON \"order_claim_item\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "order_claim_item_pkey", @@ -4722,7 +4717,6 @@ "id" ], "referencedTableName": "public.order_claim", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" }, @@ -4736,7 +4730,6 @@ "id" ], "referencedTableName": "public.order_line_item", - "createForeignKeyConstraint": true, "updateRule": "cascade" } }, @@ -4823,7 +4816,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_claim_item_id\" ON \"order_claim_item_image\" (claim_item_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_claim_item_id\" ON \"order_claim_item_image\" (\"claim_item_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_claim_item_image_deleted_at", @@ -4832,7 +4825,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_deleted_at\" ON \"order_claim_item_image\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_deleted_at\" ON \"order_claim_item_image\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_order_claim_item_image_deleted_at", @@ -4841,7 +4834,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_deleted_at\" ON \"order_claim_item_image\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_claim_item_image_deleted_at\" ON \"order_claim_item_image\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "order_claim_item_image_pkey", @@ -4866,7 +4859,6 @@ "id" ], "referencedTableName": "public.order_claim_item", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" } @@ -4972,7 +4964,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_parent_return_reason_id\" ON \"return_reason\" (parent_return_reason_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_parent_return_reason_id\" ON \"return_reason\" (\"parent_return_reason_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_return_reason_deleted_at", @@ -4981,7 +4973,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_deleted_at\" ON \"return_reason\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_deleted_at\" ON \"return_reason\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_return_reason_deleted_at", @@ -4990,7 +4982,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_deleted_at\" ON \"return_reason\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_deleted_at\" ON \"return_reason\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_return_reason_value", @@ -4999,7 +4991,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_value\" ON \"return_reason\" (value) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_value\" ON \"return_reason\" (\"value\") WHERE deleted_at IS NULL" }, { "keyName": "return_reason_pkey", @@ -5024,7 +5016,6 @@ "id" ], "referencedTableName": "public.return_reason", - "createForeignKeyConstraint": true, "deleteRule": "set null", "updateRule": "cascade" } @@ -5132,6 +5123,7 @@ "autoincrement": false, "primary": false, "nullable": false, + "default": "'{\"value\":\"0\",\"precision\":20}'", "mappedType": "json" }, "raw_damaged_quantity": { @@ -5141,6 +5133,7 @@ "autoincrement": false, "primary": false, "nullable": false, + "default": "'{\"value\":\"0\",\"precision\":20}'", "mappedType": "json" }, "created_at": { @@ -5186,7 +5179,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_reason_id\" ON \"return_item\" (reason_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_reason_id\" ON \"return_item\" (\"reason_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_return_item_return_id", @@ -5195,7 +5188,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_return_id\" ON \"return_item\" (return_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_return_id\" ON \"return_item\" (\"return_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_return_item_item_id", @@ -5204,7 +5197,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_item_id\" ON \"return_item\" (item_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_item_id\" ON \"return_item\" (\"item_id\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_return_item_deleted_at", @@ -5213,7 +5206,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_deleted_at\" ON \"return_item\" (deleted_at) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_deleted_at\" ON \"return_item\" (\"deleted_at\") WHERE deleted_at IS NULL" }, { "keyName": "IDX_return_item_deleted_at", @@ -5222,7 +5215,7 @@ "constraint": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_deleted_at\" ON \"return_item\" (deleted_at) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_item_deleted_at\" ON \"return_item\" (\"deleted_at\") WHERE deleted_at IS NOT NULL" }, { "keyName": "return_item_pkey", @@ -5247,7 +5240,6 @@ "id" ], "referencedTableName": "public.return_reason", - "createForeignKeyConstraint": true, "deleteRule": "set null", "updateRule": "cascade" }, @@ -5261,7 +5253,6 @@ "id" ], "referencedTableName": "public.return", - "createForeignKeyConstraint": true, "deleteRule": "cascade", "updateRule": "cascade" }, @@ -5275,7 +5266,6 @@ "id" ], "referencedTableName": "public.order_line_item", - "createForeignKeyConstraint": true, "updateRule": "cascade" } }, diff --git a/packages/modules/order/src/migrations/Migration20251016182939.ts b/packages/modules/order/src/migrations/Migration20251016182939.ts index 2f71953bb9..a8d4182e40 100644 --- a/packages/modules/order/src/migrations/Migration20251016182939.ts +++ b/packages/modules/order/src/migrations/Migration20251016182939.ts @@ -1,4 +1,4 @@ -import { Migration } from "@mikro-orm/migrations" +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251016182939 extends Migration { override async up(): Promise { diff --git a/packages/modules/order/src/migrations/Migration20251017155709.ts b/packages/modules/order/src/migrations/Migration20251017155709.ts index ffb0332b15..82336225ef 100644 --- a/packages/modules/order/src/migrations/Migration20251017155709.ts +++ b/packages/modules/order/src/migrations/Migration20251017155709.ts @@ -1,25 +1,31 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251017155709 extends Migration { - override async up(): Promise { - this.addSql(`drop index if exists "IDX_order_item_version";`); + this.addSql(`drop index if exists "IDX_order_item_version";`) - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_order_item_order_id_version" ON "order_item" (order_id, version) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_order_item_order_id_version" ON "order_item" (order_id, version) WHERE deleted_at IS NULL;` + ) - this.addSql(`drop index if exists "IDX_order_shipping_version";`); + this.addSql(`drop index if exists "IDX_order_shipping_version";`) - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_order_shipping_order_id_version" ON "order_shipping" (order_id, version) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_order_shipping_order_id_version" ON "order_shipping" (order_id, version) WHERE deleted_at IS NULL;` + ) } override async down(): Promise { - this.addSql(`drop index if exists "IDX_order_item_order_id_version";`); + this.addSql(`drop index if exists "IDX_order_item_order_id_version";`) - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_order_item_version" ON "order_item" (order_id, version) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_order_item_version" ON "order_item" (order_id, version) WHERE deleted_at IS NULL;` + ) - this.addSql(`drop index if exists "IDX_order_shipping_order_id_version";`); + this.addSql(`drop index if exists "IDX_order_shipping_order_id_version";`) - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_order_shipping_version" ON "order_shipping" (order_id, version) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_order_shipping_version" ON "order_shipping" (order_id, version) WHERE deleted_at IS NULL;` + ) } - } diff --git a/packages/modules/order/src/migrations/Migration20251114100559.ts b/packages/modules/order/src/migrations/Migration20251114100559.ts new file mode 100644 index 0000000000..9800fdd313 --- /dev/null +++ b/packages/modules/order/src/migrations/Migration20251114100559.ts @@ -0,0 +1,131 @@ +import { Migration } from "@medusajs/framework/mikro-orm/migrations" + +export class Migration20251114100559 extends Migration { + override async up(): Promise { + this.addSql( + `alter table if exists "order" add column if not exists "custom_display_id" text null;` + ) + this.addSql( + `CREATE UNIQUE INDEX IF NOT EXISTS "IDX_order_custom_display_id" ON "order" ("custom_display_id") WHERE deleted_at IS NULL;` + ) + + this.addSql( + `alter table if exists "order_item" alter column "raw_fulfilled_quantity" type jsonb using ("raw_fulfilled_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_fulfilled_quantity" set default '{"value":"0","precision":20}';` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_delivered_quantity" type jsonb using ("raw_delivered_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_delivered_quantity" set default '{"value":"0","precision":20}';` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_shipped_quantity" type jsonb using ("raw_shipped_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_shipped_quantity" set default '{"value":"0","precision":20}';` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_return_requested_quantity" type jsonb using ("raw_return_requested_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_return_requested_quantity" set default '{"value":"0","precision":20}';` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_return_received_quantity" type jsonb using ("raw_return_received_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_return_received_quantity" set default '{"value":"0","precision":20}';` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_return_dismissed_quantity" type jsonb using ("raw_return_dismissed_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_return_dismissed_quantity" set default '{"value":"0","precision":20}';` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_written_off_quantity" type jsonb using ("raw_written_off_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_written_off_quantity" set default '{"value":"0","precision":20}';` + ) + + this.addSql( + `alter table if exists "return_item" alter column "raw_received_quantity" type jsonb using ("raw_received_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "return_item" alter column "raw_received_quantity" set default '{"value":"0","precision":20}';` + ) + this.addSql( + `alter table if exists "return_item" alter column "raw_damaged_quantity" type jsonb using ("raw_damaged_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "return_item" alter column "raw_damaged_quantity" set default '{"value":"0","precision":20}';` + ) + } + + override async down(): Promise { + this.addSql(`drop index if exists "IDX_order_custom_display_id";`) + this.addSql( + `alter table if exists "order" drop column if exists "custom_display_id";` + ) + + this.addSql( + `alter table if exists "order_item" alter column "raw_fulfilled_quantity" drop default;` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_fulfilled_quantity" type jsonb using ("raw_fulfilled_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_delivered_quantity" drop default;` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_delivered_quantity" type jsonb using ("raw_delivered_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_shipped_quantity" drop default;` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_shipped_quantity" type jsonb using ("raw_shipped_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_return_requested_quantity" drop default;` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_return_requested_quantity" type jsonb using ("raw_return_requested_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_return_received_quantity" drop default;` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_return_received_quantity" type jsonb using ("raw_return_received_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_return_dismissed_quantity" drop default;` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_return_dismissed_quantity" type jsonb using ("raw_return_dismissed_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_written_off_quantity" drop default;` + ) + this.addSql( + `alter table if exists "order_item" alter column "raw_written_off_quantity" type jsonb using ("raw_written_off_quantity"::jsonb);` + ) + + this.addSql( + `alter table if exists "return_item" alter column "raw_received_quantity" drop default;` + ) + this.addSql( + `alter table if exists "return_item" alter column "raw_received_quantity" type jsonb using ("raw_received_quantity"::jsonb);` + ) + this.addSql( + `alter table if exists "return_item" alter column "raw_damaged_quantity" drop default;` + ) + this.addSql( + `alter table if exists "return_item" alter column "raw_damaged_quantity" type jsonb using ("raw_damaged_quantity"::jsonb);` + ) + } +} diff --git a/packages/modules/order/src/models/order.ts b/packages/modules/order/src/models/order.ts index a392990bd9..f2a6489b00 100644 --- a/packages/modules/order/src/models/order.ts +++ b/packages/modules/order/src/models/order.ts @@ -11,6 +11,7 @@ const _Order = model .define("Order", { id: model.id({ prefix: "order" }).primaryKey(), display_id: model.autoincrement().searchable(), + custom_display_id: model.text().nullable(), region_id: model.text().nullable(), customer_id: model.text().nullable(), version: model.number().default(1), @@ -71,6 +72,12 @@ const _Order = model unique: false, where: "deleted_at IS NULL", }, + { + name: "IDX_order_custom_display_id", + on: ["custom_display_id"], + unique: true, + where: "deleted_at IS NULL", + }, { name: "IDX_order_region_id", on: ["region_id"], diff --git a/packages/modules/order/src/schema/index.ts b/packages/modules/order/src/schema/index.ts index fd36cf4a93..3b76b33346 100644 --- a/packages/modules/order/src/schema/index.ts +++ b/packages/modules/order/src/schema/index.ts @@ -249,6 +249,8 @@ type Order { status: OrderStatus! region_id: String customer_id: String + display_id: String + custom_display_id: String sales_channel_id: String email: String currency_code: String! diff --git a/packages/modules/order/src/services/order-module-service.ts b/packages/modules/order/src/services/order-module-service.ts index 1476e82f2e..686cd1364e 100644 --- a/packages/modules/order/src/services/order-module-service.ts +++ b/packages/modules/order/src/services/order-module-service.ts @@ -7,7 +7,6 @@ import { FilterableOrderReturnReasonProps, FindConfig, InferEntityType, - InternalModuleDeclaration, IOrderModuleService, ModuleJoinerConfig, ModulesSdkTypes, @@ -218,6 +217,14 @@ export default class OrderModuleService }>(generateMethodForModels) implements IOrderModuleService { + protected generateCustomDisplayId_: ( + this: OrderModuleService, + order: OrderTypes.CreateOrderDTO, + sharedContext: Context + ) => Promise = async () => { + return undefined + } + protected baseRepository_: DAL.RepositoryService protected orderService_: OrderService protected orderAddressService_: ModulesSdkTypes.IMedusaInternalService< @@ -311,7 +318,12 @@ export default class OrderModuleService orderExchangeService, orderCreditLineService, }: InjectedDependencies, - protected readonly moduleDeclaration: InternalModuleDeclaration + options?: { + generateCustomDisplayId?: ( + order: OrderTypes.CreateOrderDTO, + sharedContext: Context + ) => Promise + } ) { // @ts-ignore super(...arguments) @@ -338,6 +350,9 @@ export default class OrderModuleService this.orderClaimService_ = orderClaimService this.orderExchangeService_ = orderExchangeService this.orderCreditLineService_ = orderCreditLineService + + this.generateCustomDisplayId_ = + options?.generateCustomDisplayId ?? this.generateCustomDisplayId_ } __joinerConfig(): ModuleJoinerConfig { @@ -740,14 +755,15 @@ export default class OrderModuleService const creditLinesToCreate: CreateOrderCreditLineDTO[] = [] const createdOrders: InferEntityType[] = [] - for (const { - items, - shipping_methods, - credit_lines, - shipping_address, - billing_address, - ...order - } of data) { + for (const data_ of data) { + const { + items, + shipping_methods, + credit_lines, + shipping_address, + billing_address, + ...order + } = data_ const ord = order as any const shippingMethods = shipping_methods?.map((sm: any) => { @@ -777,6 +793,11 @@ export default class OrderModuleService totals: calculated.summary, } + ord.custom_display_id = await this.generateCustomDisplayId_.bind(this)( + data_, + sharedContext + ) + const created = await this.orderService_.create(ord, sharedContext) creditLinesToCreate.push( diff --git a/packages/modules/product/src/migrations/Migration20250911092221.ts b/packages/modules/product/src/migrations/Migration20250911092221.ts index 26feb73e03..e78aa8f440 100644 --- a/packages/modules/product/src/migrations/Migration20250911092221.ts +++ b/packages/modules/product/src/migrations/Migration20250911092221.ts @@ -1,13 +1,13 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20250911092221 extends Migration { - override async up(): Promise { - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_product_status" ON "product" (status) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_product_status" ON "product" (status) WHERE deleted_at IS NULL;` + ) } override async down(): Promise { - this.addSql(`drop index if exists "IDX_product_status";`); + this.addSql(`drop index if exists "IDX_product_status";`) } - } diff --git a/packages/modules/product/src/migrations/Migration20251011090511.ts b/packages/modules/product/src/migrations/Migration20251011090511.ts index cddcb8ca85..310c436f4e 100644 --- a/packages/modules/product/src/migrations/Migration20251011090511.ts +++ b/packages/modules/product/src/migrations/Migration20251011090511.ts @@ -1,18 +1,15 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251011090511 extends Migration { -// UP: Fixes the bug by dropping the bad index from product_collection. + // UP: Fixes the bug by dropping the bad index from product_collection. override async up(): Promise { - this.addSql( - 'DROP INDEX IF EXISTS "IDX_product_category_deleted_at";' - ); + this.addSql('DROP INDEX IF EXISTS "IDX_product_category_deleted_at";') } // DOWN: Reverts the fix by re-creating the original bug. override async down(): Promise { this.addSql( 'CREATE INDEX IF NOT EXISTS "IDX_product_category_deleted_at" ON "product_collection" ("deleted_at");' - ); + ) } - } diff --git a/packages/modules/promotion/src/migrations/Migration20250917143818.ts b/packages/modules/promotion/src/migrations/Migration20250917143818.ts index 7294c8397c..aaa2c8be07 100644 --- a/packages/modules/promotion/src/migrations/Migration20250917143818.ts +++ b/packages/modules/promotion/src/migrations/Migration20250917143818.ts @@ -1,19 +1,25 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20250917143818 extends Migration { - override async up(): Promise { - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_promotion_is_automatic" ON "promotion" (is_automatic) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_promotion_is_automatic" ON "promotion" (is_automatic) WHERE deleted_at IS NULL;` + ) - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_promotion_rule_value_rule_id_value" ON "promotion_rule_value" (promotion_rule_id, value) WHERE deleted_at IS NULL;`); - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_promotion_rule_value_value" ON "promotion_rule_value" (value) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_promotion_rule_value_rule_id_value" ON "promotion_rule_value" (promotion_rule_id, value) WHERE deleted_at IS NULL;` + ) + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_promotion_rule_value_value" ON "promotion_rule_value" (value) WHERE deleted_at IS NULL;` + ) } override async down(): Promise { - this.addSql(`drop index if exists "IDX_promotion_is_automatic";`); + this.addSql(`drop index if exists "IDX_promotion_is_automatic";`) - this.addSql(`drop index if exists "IDX_promotion_rule_value_rule_id_value";`); - this.addSql(`drop index if exists "IDX_promotion_rule_value_value";`); + this.addSql( + `drop index if exists "IDX_promotion_rule_value_rule_id_value";` + ) + this.addSql(`drop index if exists "IDX_promotion_rule_value_value";`) } - } diff --git a/packages/modules/promotion/src/migrations/Migration20250919122137.ts b/packages/modules/promotion/src/migrations/Migration20250919122137.ts index 39807f6f4c..b23fb8c358 100644 --- a/packages/modules/promotion/src/migrations/Migration20250919122137.ts +++ b/packages/modules/promotion/src/migrations/Migration20250919122137.ts @@ -1,13 +1,15 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20250919122137 extends Migration { - override async up(): Promise { - this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_promotion_rule_attribute_operator_id" ON "promotion_rule" (operator, attribute, id) WHERE deleted_at IS NULL;`); + this.addSql( + `CREATE INDEX IF NOT EXISTS "IDX_promotion_rule_attribute_operator_id" ON "promotion_rule" (operator, attribute, id) WHERE deleted_at IS NULL;` + ) } override async down(): Promise { - this.addSql(`drop index if exists "IDX_promotion_rule_attribute_operator_id";`); + this.addSql( + `drop index if exists "IDX_promotion_rule_attribute_operator_id";` + ) } - } diff --git a/packages/modules/promotion/src/migrations/Migration20251006000000.ts b/packages/modules/promotion/src/migrations/Migration20251006000000.ts index 2123f53adc..5ab3c5f45c 100644 --- a/packages/modules/promotion/src/migrations/Migration20251006000000.ts +++ b/packages/modules/promotion/src/migrations/Migration20251006000000.ts @@ -1,15 +1,21 @@ -import { Migration } from '@mikro-orm/migrations'; +import { Migration } from "@medusajs/framework/mikro-orm/migrations" export class Migration20251006000000 extends Migration { - override async up(): Promise { - this.addSql(`ALTER TABLE "promotion_application_method" DROP CONSTRAINT IF EXISTS "promotion_application_method_allocation_check";`); - this.addSql(`ALTER TABLE "promotion_application_method" ADD CONSTRAINT "promotion_application_method_allocation_check" CHECK ("allocation" IN ('each', 'across', 'once'));`); + this.addSql( + `ALTER TABLE "promotion_application_method" DROP CONSTRAINT IF EXISTS "promotion_application_method_allocation_check";` + ) + this.addSql( + `ALTER TABLE "promotion_application_method" ADD CONSTRAINT "promotion_application_method_allocation_check" CHECK ("allocation" IN ('each', 'across', 'once'));` + ) } override async down(): Promise { - this.addSql(`ALTER TABLE "promotion_application_method" DROP CONSTRAINT IF EXISTS "promotion_application_method_allocation_check";`); - this.addSql(`ALTER TABLE "promotion_application_method" ADD CONSTRAINT "promotion_application_method_allocation_check" CHECK ("allocation" IN ('each', 'across'));`); + this.addSql( + `ALTER TABLE "promotion_application_method" DROP CONSTRAINT IF EXISTS "promotion_application_method_allocation_check";` + ) + this.addSql( + `ALTER TABLE "promotion_application_method" ADD CONSTRAINT "promotion_application_method_allocation_check" CHECK ("allocation" IN ('each', 'across'));` + ) } - }