From d9cbe1f9a199618751ab2cea6a95a95b25aaa9aa Mon Sep 17 00:00:00 2001 From: Riqwan Thamir Date: Wed, 21 Aug 2024 18:46:15 +0200 Subject: [PATCH 1/4] chore(order): align mikroorm <> order module --- .../migrations/.snapshot-medusa-order.json | 2875 +++++++++++++++-- .../src/migrations/Migration20240821164505.ts | 75 + .../modules/order/src/models/claim-item.ts | 9 +- .../modules/order/src/models/order-item.ts | 11 +- .../order/src/models/order-shipping-method.ts | 17 +- .../modules/order/src/models/order-summary.ts | 8 +- .../modules/order/src/models/return-item.ts | 11 +- .../modules/order/src/models/transaction.ts | 20 +- 8 files changed, 2641 insertions(+), 385 deletions(-) create mode 100644 packages/modules/order/src/migrations/Migration20240821164505.ts diff --git a/packages/modules/order/src/migrations/.snapshot-medusa-order.json b/packages/modules/order/src/migrations/.snapshot-medusa-order.json index ae3f50d03fa57..f96c32db2568c 100644 --- a/packages/modules/order/src/migrations/.snapshot-medusa-order.json +++ b/packages/modules/order/src/migrations/.snapshot-medusa-order.json @@ -411,6 +411,16 @@ "length": 6, "default": "now()", "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" } }, "name": "order_line_item", @@ -424,7 +434,7 @@ "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_variant_id\" ON \"order_line_item\" (variant_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_variant_id\" ON \"order_line_item\" (variant_id) WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_line_item_product_id", @@ -434,7 +444,17 @@ "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_product_id\" ON \"order_line_item\" (product_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_line_item_product_id\" ON \"order_line_item\" (product_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_line_item_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": 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" }, { "keyName": "order_line_item_pkey", @@ -536,6 +556,16 @@ "default": "now()", "mappedType": "datetime" }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, "item_id": { "name": "item_id", "type": "text", @@ -673,6 +703,16 @@ "default": "now()", "mappedType": "datetime" }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, "item_id": { "name": "item_id", "type": "text", @@ -1067,143 +1107,155 @@ "nullable": false, "mappedType": "integer" }, - "description": { - "name": "description", + "item_id": { + "name": "item_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "text" }, - "status": { - "name": "status", - "type": "text", + "quantity": { + "name": "quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "'pending'", - "enumItems": [ - "confirmed", - "declined", - "requested", - "pending", - "canceled" - ], - "mappedType": "enum" + "mappedType": "decimal" }, - "internal_note": { - "name": "internal_note", - "type": "text", + "raw_quantity": { + "name": "raw_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "json" }, - "created_by": { - "name": "created_by", - "type": "text", + "fulfilled_quantity": { + "name": "fulfilled_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "0", + "mappedType": "decimal" }, - "requested_by": { - "name": "requested_by", - "type": "text", + "raw_fulfilled_quantity": { + "name": "raw_fulfilled_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "json" }, - "requested_at": { - "name": "requested_at", - "type": "timestamptz", + "shipped_quantity": { + "name": "shipped_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" + "nullable": false, + "default": "0", + "mappedType": "decimal" }, - "confirmed_by": { - "name": "confirmed_by", - "type": "text", + "raw_shipped_quantity": { + "name": "raw_shipped_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "json" }, - "confirmed_at": { - "name": "confirmed_at", - "type": "timestamptz", + "return_requested_quantity": { + "name": "return_requested_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" + "nullable": false, + "default": "0", + "mappedType": "decimal" }, - "declined_by": { - "name": "declined_by", - "type": "text", + "raw_return_requested_quantity": { + "name": "raw_return_requested_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "json" }, - "declined_reason": { - "name": "declined_reason", - "type": "text", + "return_received_quantity": { + "name": "return_received_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "default": "0", + "mappedType": "decimal" }, - "metadata": { - "name": "metadata", + "raw_return_received_quantity": { + "name": "raw_return_received_quantity", "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, "mappedType": "json" }, - "declined_at": { - "name": "declined_at", - "type": "timestamptz", + "return_dismissed_quantity": { + "name": "return_dismissed_quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" + "nullable": false, + "default": "0", + "mappedType": "decimal" }, - "canceled_by": { - "name": "canceled_by", - "type": "text", + "raw_return_dismissed_quantity": { + "name": "raw_return_dismissed_quantity", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "mappedType": "text" + "nullable": false, + "mappedType": "json" }, - "canceled_at": { - "name": "canceled_at", - "type": "timestamptz", + "written_off_quantity": { + "name": "written_off_quantity", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "0", + "mappedType": "decimal" + }, + "raw_written_off_quantity": { + "name": "raw_written_off_quantity", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", "unsigned": false, "autoincrement": false, "primary": false, "nullable": true, - "length": 6, - "mappedType": "datetime" + "mappedType": "json" }, "created_at": { "name": "created_at", @@ -1226,51 +1278,63 @@ "length": 6, "default": "now()", "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" } }, - "name": "order_change", + "name": "order_item", "schema": "public", "indexes": [ { - "keyName": "IDX_order_change_order_id", + "keyName": "IDX_order_item_order_id", "columnNames": [ "order_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id\" ON \"order_change\" (order_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_order_id\" ON \"order_item\" (order_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_order_id_version", + "keyName": "IDX_order_item_version", "columnNames": [ "version" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id_version\" ON \"order_change\" (order_id, version)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_version\" ON \"order_item\" (version) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_status", + "keyName": "IDX_order_item_item_id", "columnNames": [ - "status" + "item_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_status\" ON \"order_change\" (status)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_item_id\" ON \"order_item\" (item_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_order_id_version", - "columnNames": [], + "keyName": "IDX_order_item_deleted_at", + "columnNames": [ + "deleted_at" + ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id_version\" ON \"order_change\" (order_id, version)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_deleted_at\" ON \"order_item\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_change_pkey", + "keyName": "order_item_pkey", "columnNames": [ "id" ], @@ -1281,17 +1345,28 @@ ], "checks": [], "foreignKeys": { - "order_change_order_id_foreign": { - "constraintName": "order_change_order_id_foreign", + "order_item_order_id_foreign": { + "constraintName": "order_item_order_id_foreign", "columnNames": [ "order_id" ], - "localTableName": "public.order_change", + "localTableName": "public.order_item", "referencedColumnNames": [ "id" ], "referencedTableName": "public.order", - "deleteRule": "cascade", + "updateRule": "cascade" + }, + "order_item_item_id_foreign": { + "constraintName": "order_item_item_id_foreign", + "columnNames": [ + "item_id" + ], + "localTableName": "public.order_item", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_line_item", "updateRule": "cascade" } } @@ -1307,22 +1382,1798 @@ "nullable": false, "mappedType": "text" }, - "ordering": { - "name": "ordering", - "type": "integer", - "unsigned": true, - "autoincrement": true, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, "order_id": { "name": "order_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, + "nullable": false, + "mappedType": "text" + }, + "version": { + "name": "version", + "type": "integer", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "1", + "mappedType": "integer" + }, + "totals": { + "name": "totals", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "order_summary", + "schema": "public", + "indexes": [ + { + "keyName": "IDX_order_summary_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": 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" + }, + { + "keyName": "IDX_order_summary_order_id_version", + "columnNames": [], + "composite": 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 NOT NULL" + }, + { + "keyName": "order_summary_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_summary_order_id_foreign": { + "constraintName": "order_summary_order_id_foreign", + "columnNames": [ + "order_id" + ], + "localTableName": "public.order_summary", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order", + "deleteRule": "cascade", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "order_id": { + "name": "order_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "exchange_id": { + "name": "exchange_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "claim_id": { + "name": "claim_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "order_version": { + "name": "order_version", + "type": "integer", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "display_id": { + "name": "display_id", + "type": "serial", + "unsigned": true, + "autoincrement": true, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "status": { + "name": "status", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "'open'", + "enumItems": [ + "open", + "requested", + "received", + "partially_received", + "canceled" + ], + "mappedType": "enum" + }, + "location_id": { + "name": "location_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "no_notification": { + "name": "no_notification", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "boolean" + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "decimal" + }, + "raw_refund_amount": { + "name": "raw_refund_amount", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "requested_at": { + "name": "requested_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "received_at": { + "name": "received_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "return", + "schema": "public", + "indexes": [ + { + "columnNames": [ + "exchange_id" + ], + "composite": false, + "keyName": "return_exchange_id_unique", + "primary": false, + "unique": true + }, + { + "columnNames": [ + "claim_id" + ], + "composite": false, + "keyName": "return_claim_id_unique", + "primary": false, + "unique": true + }, + { + "keyName": "IDX_return_order_id", + "columnNames": [ + "order_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_order_id\" ON \"return\" (order_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_return_exchange_id", + "columnNames": [ + "exchange_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_return_claim_id", + "columnNames": [ + "claim_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_return_display_id", + "columnNames": [ + "display_id" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_display_id\" ON \"return\" (display_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_return_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": 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" + }, + { + "keyName": "return_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "return_order_id_foreign": { + "constraintName": "return_order_id_foreign", + "columnNames": [ + "order_id" + ], + "localTableName": "public.return", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order", + "updateRule": "cascade" + }, + "return_exchange_id_foreign": { + "constraintName": "return_exchange_id_foreign", + "columnNames": [ + "exchange_id" + ], + "localTableName": "public.return", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_exchange", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "return_claim_id_foreign": { + "constraintName": "return_claim_id_foreign", + "columnNames": [ + "claim_id" + ], + "localTableName": "public.return", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_claim", + "deleteRule": "set null", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "order_id": { + "name": "order_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "return_id": { + "name": "return_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "order_version": { + "name": "order_version", + "type": "integer", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "display_id": { + "name": "display_id", + "type": "serial", + "unsigned": true, + "autoincrement": true, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "no_notification": { + "name": "no_notification", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "boolean" + }, + "difference_due": { + "name": "difference_due", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "decimal" + }, + "raw_difference_due": { + "name": "raw_difference_due", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "allow_backorder": { + "name": "allow_backorder", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "order_exchange", + "schema": "public", + "indexes": [ + { + "columnNames": [ + "return_id" + ], + "composite": false, + "keyName": "order_exchange_return_id_unique", + "primary": false, + "unique": true + }, + { + "keyName": "IDX_order_exchange_order_id", + "columnNames": [ + "order_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_exchange_return_id", + "columnNames": [ + "return_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_exchange_display_id", + "columnNames": [ + "display_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_exchange_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": 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" + }, + { + "keyName": "order_exchange_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_exchange_order_id_foreign": { + "constraintName": "order_exchange_order_id_foreign", + "columnNames": [ + "order_id" + ], + "localTableName": "public.order_exchange", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order", + "updateRule": "cascade" + }, + "order_exchange_return_id_foreign": { + "constraintName": "order_exchange_return_id_foreign", + "columnNames": [ + "return_id" + ], + "localTableName": "public.order_exchange", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.return", + "deleteRule": "set null", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "quantity": { + "name": "quantity", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "decimal" + }, + "raw_quantity": { + "name": "raw_quantity", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, + "exchange_id": { + "name": "exchange_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "item_id": { + "name": "item_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "note": { + "name": "note", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "order_exchange_item", + "schema": "public", + "indexes": [ + { + "keyName": "IDX_order_exchange_item_exchange_id", + "columnNames": [ + "exchange_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_exchange_item_item_id", + "columnNames": [ + "item_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_claim_item_image_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": 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" + }, + { + "keyName": "order_exchange_item_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_exchange_item_exchange_id_foreign": { + "constraintName": "order_exchange_item_exchange_id_foreign", + "columnNames": [ + "exchange_id" + ], + "localTableName": "public.order_exchange_item", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_exchange", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "order_exchange_item_item_id_foreign": { + "constraintName": "order_exchange_item_item_id_foreign", + "columnNames": [ + "item_id" + ], + "localTableName": "public.order_exchange_item", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_line_item", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "order_id": { + "name": "order_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "return_id": { + "name": "return_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "order_version": { + "name": "order_version", + "type": "integer", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "display_id": { + "name": "display_id", + "type": "serial", + "unsigned": true, + "autoincrement": true, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "type": { + "name": "type", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "enumItems": [ + "refund", + "replace" + ], + "mappedType": "enum" + }, + "no_notification": { + "name": "no_notification", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "boolean" + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "decimal" + }, + "raw_refund_amount": { + "name": "raw_refund_amount", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "order_claim", + "schema": "public", + "indexes": [ + { + "columnNames": [ + "return_id" + ], + "composite": false, + "keyName": "order_claim_return_id_unique", + "primary": false, + "unique": true + }, + { + "keyName": "IDX_order_claim_order_id", + "columnNames": [ + "order_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_claim_return_id", + "columnNames": [ + "return_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_claim_display_id", + "columnNames": [ + "display_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_claim_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": 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" + }, + { + "keyName": "order_claim_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_claim_order_id_foreign": { + "constraintName": "order_claim_order_id_foreign", + "columnNames": [ + "order_id" + ], + "localTableName": "public.order_claim", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order", + "updateRule": "cascade" + }, + "order_claim_return_id_foreign": { + "constraintName": "order_claim_return_id_foreign", + "columnNames": [ + "return_id" + ], + "localTableName": "public.order_claim", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.return", + "deleteRule": "set null", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "reason": { + "name": "reason", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "enumItems": [ + "missing_item", + "wrong_item", + "production_failure", + "other" + ], + "mappedType": "enum" + }, + "quantity": { + "name": "quantity", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "decimal" + }, + "raw_quantity": { + "name": "raw_quantity", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, + "claim_id": { + "name": "claim_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "item_id": { + "name": "item_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "is_additional_item": { + "name": "is_additional_item", + "type": "boolean", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "false", + "mappedType": "boolean" + }, + "note": { + "name": "note", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "order_claim_item", + "schema": "public", + "indexes": [ + { + "keyName": "IDX_order_claim_item_claim_id", + "columnNames": [ + "claim_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_claim_item_item_id", + "columnNames": [ + "item_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_claim_item_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": 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" + }, + { + "keyName": "order_claim_item_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_claim_item_claim_id_foreign": { + "constraintName": "order_claim_item_claim_id_foreign", + "columnNames": [ + "claim_id" + ], + "localTableName": "public.order_claim_item", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_claim", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "order_claim_item_item_id_foreign": { + "constraintName": "order_claim_item_item_id_foreign", + "columnNames": [ + "item_id" + ], + "localTableName": "public.order_claim_item", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_line_item", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "claim_item_id": { + "name": "claim_item_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "url": { + "name": "url", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "order_claim_item_image", + "schema": "public", + "indexes": [ + { + "keyName": "IDX_order_claim_item_image_claim_item_id", + "columnNames": [ + "claim_item_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_claim_item_image_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": 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" + }, + { + "keyName": "order_claim_item_image_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_claim_item_image_claim_item_id_foreign": { + "constraintName": "order_claim_item_image_claim_item_id_foreign", + "columnNames": [ + "claim_item_id" + ], + "localTableName": "public.order_claim_item_image", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_claim_item", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "order_id": { + "name": "order_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "return_id": { + "name": "return_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "claim_id": { + "name": "claim_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "exchange_id": { + "name": "exchange_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "version": { + "name": "version", + "type": "integer", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "change_type": { + "name": "change_type", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "description": { + "name": "description", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "status": { + "name": "status", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "'pending'", + "enumItems": [ + "confirmed", + "declined", + "requested", + "pending", + "canceled" + ], + "mappedType": "enum" + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "created_by": { + "name": "created_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "requested_by": { + "name": "requested_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "requested_at": { + "name": "requested_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "confirmed_by": { + "name": "confirmed_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "confirmed_at": { + "name": "confirmed_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "declined_by": { + "name": "declined_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "declined_reason": { + "name": "declined_reason", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, + "declined_at": { + "name": "declined_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "canceled_by": { + "name": "canceled_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, + "created_at": { + "name": "created_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "length": 6, + "default": "now()", + "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "order_change", + "schema": "public", + "indexes": [ + { + "keyName": "IDX_order_change_order_id", + "columnNames": [ + "order_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_change_return_id", + "columnNames": [ + "return_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_change_claim_id", + "columnNames": [ + "claim_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_change_exchange_id", + "columnNames": [ + "exchange_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_change_order_id_version", + "columnNames": [ + "version" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id_version\" ON \"order_change\" (order_id, version) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_status", + "columnNames": [ + "status" + ], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_status\" ON \"order_change\" (status) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_change_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": 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" + }, + { + "keyName": "IDX_order_change_order_id_version", + "columnNames": [], + "composite": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_order_id_version\" ON \"order_change\" (order_id, version) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "order_change_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_change_order_id_foreign": { + "constraintName": "order_change_order_id_foreign", + "columnNames": [ + "order_id" + ], + "localTableName": "public.order_change", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "order_change_return_id_foreign": { + "constraintName": "order_change_return_id_foreign", + "columnNames": [ + "return_id" + ], + "localTableName": "public.order_change", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.return", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_change_claim_id_foreign": { + "constraintName": "order_change_claim_id_foreign", + "columnNames": [ + "claim_id" + ], + "localTableName": "public.order_change", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_claim", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_change_exchange_id_foreign": { + "constraintName": "order_change_exchange_id_foreign", + "columnNames": [ + "exchange_id" + ], + "localTableName": "public.order_change", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_exchange", + "deleteRule": "set null", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "ordering": { + "name": "ordering", + "type": "integer", + "unsigned": true, + "autoincrement": true, + "primary": false, + "nullable": false, + "mappedType": "integer" + }, + "order_id": { + "name": "order_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "return_id": { + "name": "return_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "claim_id": { + "name": "claim_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "exchange_id": { + "name": "exchange_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, "mappedType": "text" }, "version": { @@ -1437,6 +3288,16 @@ "length": 6, "default": "now()", "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" } }, "name": "order_change_action", @@ -1450,7 +3311,7 @@ "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_ordering\" ON \"order_change_action\" (ordering)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_ordering\" ON \"order_change_action\" (ordering) WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_change_action_order_id", @@ -1460,221 +3321,183 @@ "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_id\" ON \"order_change_action\" (order_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_change_action_order_id\" ON \"order_change_action\" (order_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_change_action_order_change_id", + "keyName": "IDX_order_change_action_return_id", "columnNames": [ - "order_change_id" + "return_id" ], "composite": 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)" + "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 NOT NULL" }, { - "keyName": "order_change_action_pkey", + "keyName": "IDX_order_change_action_claim_id", "columnNames": [ - "id" + "claim_id" ], "composite": false, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "order_change_action_order_id_foreign": { - "constraintName": "order_change_action_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.order_change_action", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order", - "deleteRule": "cascade", - "updateRule": "cascade" + "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 NOT NULL" }, - "order_change_action_order_change_id_foreign": { - "constraintName": "order_change_action_order_change_id_foreign", + { + "keyName": "IDX_order_change_action_exchange_id", "columnNames": [ - "order_change_id" - ], - "localTableName": "public.order_change_action", - "referencedColumnNames": [ - "id" + "exchange_id" ], - "referencedTableName": "public.order_change", - "deleteRule": "cascade", - "updateRule": "cascade" - } - } - }, - { - "columns": { - "id": { - "name": "id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "order_id": { - "name": "order_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "version": { - "name": "version", - "type": "integer", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "item_id": { - "name": "item_id", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "quantity": { - "name": "quantity", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "decimal" - }, - "raw_quantity": { - "name": "raw_quantity", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "json" - }, - "fulfilled_quantity": { - "name": "fulfilled_quantity", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "decimal" - }, - "raw_fulfilled_quantity": { - "name": "raw_fulfilled_quantity", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "json" - }, - "shipped_quantity": { - "name": "shipped_quantity", - "type": "numeric", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "decimal" - }, - "raw_shipped_quantity": { - "name": "raw_shipped_quantity", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "json" - }, - "return_requested_quantity": { - "name": "return_requested_quantity", - "type": "numeric", - "unsigned": false, - "autoincrement": false, + "composite": false, "primary": false, - "nullable": false, - "mappedType": "decimal" + "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 NOT NULL" }, - "raw_return_requested_quantity": { - "name": "raw_return_requested_quantity", - "type": "jsonb", - "unsigned": false, - "autoincrement": false, + { + "keyName": "IDX_order_change_action_order_change_id", + "columnNames": [ + "order_change_id" + ], + "composite": false, "primary": false, - "nullable": false, - "mappedType": "json" + "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 NOT NULL" }, - "return_received_quantity": { - "name": "return_received_quantity", - "type": "numeric", - "unsigned": false, - "autoincrement": false, + { + "keyName": "IDX_order_change_action_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": false, "primary": false, - "nullable": false, - "mappedType": "decimal" + "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" }, - "raw_return_received_quantity": { - "name": "raw_return_received_quantity", - "type": "jsonb", + { + "keyName": "order_change_action_pkey", + "columnNames": [ + "id" + ], + "composite": false, + "primary": true, + "unique": true + } + ], + "checks": [], + "foreignKeys": { + "order_change_action_order_id_foreign": { + "constraintName": "order_change_action_order_id_foreign", + "columnNames": [ + "order_id" + ], + "localTableName": "public.order_change_action", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order", + "deleteRule": "cascade", + "updateRule": "cascade" + }, + "order_change_action_return_id_foreign": { + "constraintName": "order_change_action_return_id_foreign", + "columnNames": [ + "return_id" + ], + "localTableName": "public.order_change_action", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.return", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_change_action_claim_id_foreign": { + "constraintName": "order_change_action_claim_id_foreign", + "columnNames": [ + "claim_id" + ], + "localTableName": "public.order_change_action", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_claim", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_change_action_exchange_id_foreign": { + "constraintName": "order_change_action_exchange_id_foreign", + "columnNames": [ + "exchange_id" + ], + "localTableName": "public.order_change_action", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_exchange", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_change_action_order_change_id_foreign": { + "constraintName": "order_change_action_order_change_id_foreign", + "columnNames": [ + "order_change_id" + ], + "localTableName": "public.order_change_action", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_change", + "deleteRule": "cascade", + "updateRule": "cascade" + } + } + }, + { + "columns": { + "id": { + "name": "id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "json" + "mappedType": "text" }, - "return_dismissed_quantity": { - "name": "return_dismissed_quantity", - "type": "numeric", + "value": { + "name": "value", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "decimal" + "mappedType": "text" }, - "raw_return_dismissed_quantity": { - "name": "raw_return_dismissed_quantity", - "type": "jsonb", + "label": { + "name": "label", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "mappedType": "json" + "mappedType": "text" }, - "written_off_quantity": { - "name": "written_off_quantity", - "type": "numeric", + "description": { + "name": "description", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "decimal" + "nullable": true, + "mappedType": "text" }, - "raw_written_off_quantity": { - "name": "raw_written_off_quantity", - "type": "jsonb", + "parent_return_reason_id": { + "name": "parent_return_reason_id", + "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, - "mappedType": "json" + "nullable": true, + "mappedType": "text" }, "metadata": { "name": "metadata", @@ -1718,51 +3541,41 @@ "mappedType": "datetime" } }, - "name": "order_item", + "name": "return_reason", "schema": "public", "indexes": [ { - "keyName": "IDX_order_item_order_id", - "columnNames": [ - "order_id" - ], - "composite": 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 NOT NULL" - }, - { - "keyName": "IDX_order_item_version", + "keyName": "IDX_return_reason_value", "columnNames": [ - "version" + "value" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_item_version\" ON \"order_item\" (version) WHERE deleted_at IS NOT NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_return_reason_value\" ON \"return_reason\" (value) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_item_item_id", + "keyName": "IDX_return_reason_parent_return_reason_id", "columnNames": [ - "item_id" + "parent_return_reason_id" ], "composite": 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 NOT 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 NOT NULL" }, { - "keyName": "IDX_order_deleted_at", + "keyName": "IDX_return_reason_deleted_at", "columnNames": [ "deleted_at" ], "composite": 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_return_reason_deleted_at\" ON \"return_reason\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { - "keyName": "order_item_pkey", + "keyName": "return_reason_pkey", "columnNames": [ "id" ], @@ -1773,28 +3586,17 @@ ], "checks": [], "foreignKeys": { - "order_item_order_id_foreign": { - "constraintName": "order_item_order_id_foreign", - "columnNames": [ - "order_id" - ], - "localTableName": "public.order_item", - "referencedColumnNames": [ - "id" - ], - "referencedTableName": "public.order", - "updateRule": "cascade" - }, - "order_item_item_id_foreign": { - "constraintName": "order_item_item_id_foreign", + "return_reason_parent_return_reason_id_foreign": { + "constraintName": "return_reason_parent_return_reason_id_foreign", "columnNames": [ - "item_id" + "parent_return_reason_id" ], - "localTableName": "public.order_item", + "localTableName": "public.return_reason", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order_line_item", + "referencedTableName": "public.return_reason", + "deleteRule": "set null", "updateRule": "cascade" } } @@ -1810,27 +3612,26 @@ "nullable": false, "mappedType": "text" }, - "order_id": { - "name": "order_id", + "reason_id": { + "name": "reason_id", "type": "text", "unsigned": false, "autoincrement": false, "primary": false, - "nullable": false, + "nullable": true, "mappedType": "text" }, - "version": { - "name": "version", - "type": "integer", + "quantity": { + "name": "quantity", + "type": "numeric", "unsigned": false, "autoincrement": false, "primary": false, "nullable": false, - "default": "1", - "mappedType": "integer" + "mappedType": "decimal" }, - "totals": { - "name": "totals", + "raw_quantity": { + "name": "raw_quantity", "type": "jsonb", "unsigned": false, "autoincrement": false, @@ -1838,6 +3639,61 @@ "nullable": false, "mappedType": "json" }, + "received_quantity": { + "name": "received_quantity", + "type": "numeric", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "0", + "mappedType": "decimal" + }, + "raw_received_quantity": { + "name": "raw_received_quantity", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "json" + }, + "return_id": { + "name": "return_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "item_id": { + "name": "item_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "mappedType": "text" + }, + "note": { + "name": "note", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "json" + }, "created_at": { "name": "created_at", "type": "timestamptz", @@ -1866,34 +3722,56 @@ "unsigned": false, "autoincrement": false, "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "order_summary", - "schema": "public", - "indexes": [ + "nullable": true, + "length": 6, + "mappedType": "datetime" + } + }, + "name": "return_item", + "schema": "public", + "indexes": [ + { + "keyName": "IDX_return_item_reason_id", + "columnNames": [ + "reason_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_return_item_return_id", + "columnNames": [ + "return_id" + ], + "composite": 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 NOT NULL" + }, { - "keyName": "IDX_order_deleted_at", + "keyName": "IDX_return_item_item_id", "columnNames": [ - "deleted_at" + "item_id" ], "composite": 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_return_item_item_id\" ON \"return_item\" (item_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_summary_order_id_version", - "columnNames": [], + "keyName": "IDX_return_item_deleted_at", + "columnNames": [ + "deleted_at" + ], "composite": 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 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": "order_summary_pkey", + "keyName": "return_item_pkey", "columnNames": [ "id" ], @@ -1904,18 +3782,43 @@ ], "checks": [], "foreignKeys": { - "order_summary_order_id_foreign": { - "constraintName": "order_summary_order_id_foreign", + "return_item_reason_id_foreign": { + "constraintName": "return_item_reason_id_foreign", "columnNames": [ - "order_id" + "reason_id" ], - "localTableName": "public.order_summary", + "localTableName": "public.return_item", "referencedColumnNames": [ "id" ], - "referencedTableName": "public.order", + "referencedTableName": "public.return_reason", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "return_item_return_id_foreign": { + "constraintName": "return_item_return_id_foreign", + "columnNames": [ + "return_id" + ], + "localTableName": "public.return_item", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.return", "deleteRule": "cascade", "updateRule": "cascade" + }, + "return_item_item_id_foreign": { + "constraintName": "return_item_item_id_foreign", + "columnNames": [ + "item_id" + ], + "localTableName": "public.return_item", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_line_item", + "updateRule": "cascade" } } }, @@ -2024,6 +3927,16 @@ "length": 6, "default": "now()", "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" } }, "name": "order_shipping_method", @@ -2037,7 +3950,17 @@ "composite": 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)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_method_shipping_option_id\" ON \"order_shipping_method\" (shipping_option_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_shipping_method_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": 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 NOT NULL" }, { "keyName": "order_shipping_method_pkey", @@ -2072,6 +3995,33 @@ "nullable": false, "mappedType": "text" }, + "return_id": { + "name": "return_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "exchange_id": { + "name": "exchange_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "claim_id": { + "name": "claim_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, "version": { "name": "version", "type": "integer", @@ -2136,6 +4086,36 @@ "unique": false, "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_order_id\" ON \"order_shipping\" (order_id) WHERE deleted_at IS NOT NULL" }, + { + "keyName": "IDX_order_shipping_return_id", + "columnNames": [ + "return_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_shipping_exchange_id", + "columnNames": [ + "exchange_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_shipping_claim_id", + "columnNames": [ + "claim_id" + ], + "composite": 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 NOT NULL" + }, { "keyName": "IDX_order_shipping_version", "columnNames": [ @@ -2157,14 +4137,14 @@ "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_shipping_shipping_method_id\" ON \"order_shipping\" (shipping_method_id) WHERE deleted_at IS NOT NULL" }, { - "keyName": "IDX_order_deleted_at", + "keyName": "IDX_order_shipping_deleted_at", "columnNames": [ "deleted_at" ], "composite": 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_shipping_deleted_at\" ON \"order_shipping\" (deleted_at) WHERE deleted_at IS NOT NULL" }, { "keyName": "order_shipping_pkey", @@ -2190,6 +4170,45 @@ "referencedTableName": "public.order", "updateRule": "cascade" }, + "order_shipping_return_id_foreign": { + "constraintName": "order_shipping_return_id_foreign", + "columnNames": [ + "return_id" + ], + "localTableName": "public.order_shipping", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.return", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_shipping_exchange_id_foreign": { + "constraintName": "order_shipping_exchange_id_foreign", + "columnNames": [ + "exchange_id" + ], + "localTableName": "public.order_shipping", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_exchange", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_shipping_claim_id_foreign": { + "constraintName": "order_shipping_claim_id_foreign", + "columnNames": [ + "claim_id" + ], + "localTableName": "public.order_shipping", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_claim", + "deleteRule": "set null", + "updateRule": "cascade" + }, "order_shipping_shipping_method_id_foreign": { "constraintName": "order_shipping_shipping_method_id_foreign", "columnNames": [ @@ -2291,6 +4310,16 @@ "default": "now()", "mappedType": "datetime" }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, "shipping_method_id": { "name": "shipping_method_id", "type": "text", @@ -2428,6 +4457,16 @@ "default": "now()", "mappedType": "datetime" }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" + }, "shipping_method_id": { "name": "shipping_method_id", "type": "text", @@ -2498,6 +4537,43 @@ "nullable": false, "mappedType": "text" }, + "return_id": { + "name": "return_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "exchange_id": { + "name": "exchange_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "claim_id": { + "name": "claim_id", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "version": { + "name": "version", + "type": "integer", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": false, + "default": "1", + "mappedType": "integer" + }, "amount": { "name": "amount", "type": "numeric", @@ -2564,6 +4640,16 @@ "length": 6, "default": "now()", "mappedType": "datetime" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamptz", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "length": 6, + "mappedType": "datetime" } }, "name": "order_transaction", @@ -2577,7 +4663,37 @@ "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id\" ON \"order_transaction\" (order_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_order_id\" ON \"order_transaction\" (order_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_transaction_return_id", + "columnNames": [ + "return_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_transaction_exchange_id", + "columnNames": [ + "exchange_id" + ], + "composite": 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 NOT NULL" + }, + { + "keyName": "IDX_order_transaction_claim_id", + "columnNames": [ + "claim_id" + ], + "composite": 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 NOT NULL" }, { "keyName": "IDX_order_transaction_currency_code", @@ -2587,7 +4703,7 @@ "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_currency_code\" ON \"order_transaction\" (currency_code)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_currency_code\" ON \"order_transaction\" (currency_code) WHERE deleted_at IS NOT NULL" }, { "keyName": "IDX_order_transaction_reference_id", @@ -2597,7 +4713,25 @@ "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_reference_id\" ON \"order_transaction\" (reference_id)" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_order_transaction_reference_id\" ON \"order_transaction\" (reference_id) WHERE deleted_at IS NOT NULL" + }, + { + "keyName": "IDX_order_transaction_deleted_at", + "columnNames": [ + "deleted_at" + ], + "composite": 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" + }, + { + "keyName": "IDX_order_transaction_order_id_version", + "columnNames": [], + "composite": 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 NOT NULL" }, { "keyName": "order_transaction_pkey", @@ -2623,8 +4757,47 @@ "referencedTableName": "public.order", "deleteRule": "cascade", "updateRule": "cascade" + }, + "order_transaction_return_id_foreign": { + "constraintName": "order_transaction_return_id_foreign", + "columnNames": [ + "return_id" + ], + "localTableName": "public.order_transaction", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.return", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_transaction_exchange_id_foreign": { + "constraintName": "order_transaction_exchange_id_foreign", + "columnNames": [ + "exchange_id" + ], + "localTableName": "public.order_transaction", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_exchange", + "deleteRule": "set null", + "updateRule": "cascade" + }, + "order_transaction_claim_id_foreign": { + "constraintName": "order_transaction_claim_id_foreign", + "columnNames": [ + "claim_id" + ], + "localTableName": "public.order_transaction", + "referencedColumnNames": [ + "id" + ], + "referencedTableName": "public.order_claim", + "deleteRule": "set null", + "updateRule": "cascade" } } } ] -} \ No newline at end of file +} diff --git a/packages/modules/order/src/migrations/Migration20240821164505.ts b/packages/modules/order/src/migrations/Migration20240821164505.ts new file mode 100644 index 0000000000000..720bfb9baad31 --- /dev/null +++ b/packages/modules/order/src/migrations/Migration20240821164505.ts @@ -0,0 +1,75 @@ +import { Migration } from "@mikro-orm/migrations" + +export class Migration20240821164505 extends Migration { + async up(): Promise { + this.addSql('drop index if exists "IDX_order_deleted_at";') + this.addSql( + 'CREATE INDEX IF NOT EXISTS "IDX_order_item_deleted_at" ON "order_item" (deleted_at) WHERE deleted_at IS NOT NULL;' + ) + + this.addSql('drop index if exists "IDX_order_deleted_at";') + this.addSql( + 'CREATE INDEX IF NOT EXISTS "IDX_order_summary_deleted_at" ON "order_summary" (deleted_at) WHERE deleted_at IS NOT NULL;' + ) + + this.addSql('drop index if exists "IDX_order_claim_item_image_deleted_at";') + this.addSql( + 'CREATE INDEX IF NOT EXISTS "IDX_order_claim_item_deleted_at" ON "order_claim_item" (deleted_at) WHERE deleted_at IS NOT NULL;' + ) + + this.addSql('drop index if exists "IDX_order_claim_item_image_deleted_at";') + this.addSql( + 'CREATE INDEX IF NOT EXISTS "IDX_return_item_deleted_at" ON "return_item" (deleted_at) WHERE deleted_at IS NOT NULL;' + ) + + this.addSql('drop index if exists "IDX_order_deleted_at";') + this.addSql( + 'CREATE INDEX IF NOT EXISTS "IDX_order_shipping_deleted_at" ON "order_shipping" (deleted_at) WHERE deleted_at IS NOT NULL;' + ) + + this.addSql('drop index if exists "IDX_order_item_exchange_id";') + this.addSql('drop index if exists "IDX_order_item_claim_id";') + this.addSql( + '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 NOT NULL;' + ) + this.addSql( + '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 NOT NULL;' + ) + } + + async down(): Promise { + this.addSql('drop index if exists "IDX_order_item_deleted_at";') + this.addSql( + 'CREATE INDEX IF NOT EXISTS "IDX_order_deleted_at" ON "order" (deleted_at) WHERE deleted_at IS NOT NULL;' + ) + + this.addSql('drop index if exists "IDX_order_summary_deleted_at";') + this.addSql( + 'CREATE INDEX IF NOT EXISTS "IDX_order_deleted_at" ON "order" (deleted_at) WHERE deleted_at IS NOT NULL;' + ) + + this.addSql('drop index if exists "IDX_order_claim_item_deleted_at";') + this.addSql( + '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;' + ) + + this.addSql('drop index if exists "IDX_return_item_deleted_at";') + this.addSql( + '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;' + ) + + this.addSql('drop index if exists "IDX_order_shipping_deleted_at";') + this.addSql( + 'CREATE INDEX IF NOT EXISTS "IDX_order_deleted_at" ON "order" (deleted_at) WHERE deleted_at IS NOT NULL;' + ) + + this.addSql('drop index if exists "IDX_order_transaction_exchange_id";') + this.addSql('drop index if exists "IDX_order_transaction_claim_id";') + this.addSql( + 'CREATE INDEX IF NOT EXISTS "IDX_order_item_exchange_id" ON "order_item" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL;' + ) + this.addSql( + 'CREATE INDEX IF NOT EXISTS "IDX_order_item_claim_id" ON "order_item" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL;' + ) + } +} diff --git a/packages/modules/order/src/models/claim-item.ts b/packages/modules/order/src/models/claim-item.ts index f969537084c0a..9a080876fd141 100644 --- a/packages/modules/order/src/models/claim-item.ts +++ b/packages/modules/order/src/models/claim-item.ts @@ -25,25 +25,26 @@ import LineItem from "./line-item" type OptionalLineItemProps = DAL.ModelDateColumns +const tableName = "order_claim_item" const ClaimIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_claim_item", + tableName, columns: "claim_id", where: "deleted_at IS NOT NULL", }) const ItemIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_claim_item", + tableName, columns: "item_id", where: "deleted_at IS NOT NULL", }) const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order_claim_item_image", + tableName, columns: "deleted_at", where: "deleted_at IS NOT NULL", }) -@Entity({ tableName: "order_claim_item" }) +@Entity({ tableName }) export default class OrderClaimItem { [OptionalProps]?: OptionalLineItemProps diff --git a/packages/modules/order/src/models/order-item.ts b/packages/modules/order/src/models/order-item.ts index 68c429c2f33ae..4284f345342a1 100644 --- a/packages/modules/order/src/models/order-item.ts +++ b/packages/modules/order/src/models/order-item.ts @@ -20,31 +20,32 @@ import Order from "./order" type OptionalLineItemProps = DAL.ModelDateColumns +const tableName = "order_item" const OrderIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_item", + tableName, columns: ["order_id"], where: "deleted_at IS NOT NULL", }) const OrderVersionIndex = createPsqlIndexStatementHelper({ - tableName: "order_item", + tableName, columns: ["version"], where: "deleted_at IS NOT NULL", }) const ItemIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_item", + tableName, columns: ["item_id"], where: "deleted_at IS NOT NULL", }) const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order", + tableName, columns: "deleted_at", where: "deleted_at IS NOT NULL", }) -@Entity({ tableName: "order_item" }) +@Entity({ tableName }) export default class OrderItem { [OptionalProps]?: OptionalLineItemProps diff --git a/packages/modules/order/src/models/order-shipping-method.ts b/packages/modules/order/src/models/order-shipping-method.ts index 2dbb3e63987f2..0ac2642ffb714 100644 --- a/packages/modules/order/src/models/order-shipping-method.ts +++ b/packages/modules/order/src/models/order-shipping-method.ts @@ -21,49 +21,50 @@ import ShippingMethod from "./shipping-method" type OptionalShippingMethodProps = DAL.ModelDateColumns +const tableName = "order_shipping" const OrderIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_shipping", + tableName, columns: ["order_id"], where: "deleted_at IS NOT NULL", }) const ReturnIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_shipping", + tableName, columns: "return_id", where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", }) const ExchangeIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_shipping", + tableName, columns: ["exchange_id"], where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL", }) const ClaimIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_shipping", + tableName, columns: ["claim_id"], where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL", }) const OrderVersionIndex = createPsqlIndexStatementHelper({ - tableName: "order_shipping", + tableName, columns: ["version"], where: "deleted_at IS NOT NULL", }) const ItemIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_shipping", + tableName, columns: ["shipping_method_id"], where: "deleted_at IS NOT NULL", }) const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order", + tableName, columns: "deleted_at", where: "deleted_at IS NOT NULL", }) -@Entity({ tableName: "order_shipping" }) +@Entity({ tableName }) export default class OrderShippingMethod { [OptionalProps]?: OptionalShippingMethodProps diff --git a/packages/modules/order/src/models/order-summary.ts b/packages/modules/order/src/models/order-summary.ts index f7ed01cb713c1..399c6862e009f 100644 --- a/packages/modules/order/src/models/order-summary.ts +++ b/packages/modules/order/src/models/order-summary.ts @@ -36,19 +36,21 @@ type OrderSummaryTotals = { refunded_total: BigNumber } +const tableName = "order_summary" + const OrderIdVersionIndex = createPsqlIndexStatementHelper({ - tableName: "order_summary", + tableName, columns: ["order_id", "version"], where: "deleted_at IS NOT NULL", }) const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order", + tableName, columns: "deleted_at", where: "deleted_at IS NOT NULL", }) -@Entity({ tableName: "order_summary" }) +@Entity({ tableName }) @OrderIdVersionIndex.MikroORMIndex() export default class OrderSummary { @PrimaryKey({ columnType: "text" }) diff --git a/packages/modules/order/src/models/return-item.ts b/packages/modules/order/src/models/return-item.ts index 2db431ada9ebb..ec0846ac808a2 100644 --- a/packages/modules/order/src/models/return-item.ts +++ b/packages/modules/order/src/models/return-item.ts @@ -19,31 +19,32 @@ import ReturnReason from "./return-reason" type OptionalLineItemProps = DAL.ModelDateColumns +const tableName = "return_item" const ReturnIdIndex = createPsqlIndexStatementHelper({ - tableName: "return_item", + tableName, columns: "return_id", where: "deleted_at IS NOT NULL", }) const ReturnReasonIdIndex = createPsqlIndexStatementHelper({ - tableName: "return_item", + tableName, columns: "reason_id", where: "deleted_at IS NOT NULL", }) const ItemIdIndex = createPsqlIndexStatementHelper({ - tableName: "return_item", + tableName, columns: "item_id", where: "deleted_at IS NOT NULL", }) const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order_claim_item_image", + tableName, columns: "deleted_at", where: "deleted_at IS NOT NULL", }) -@Entity({ tableName: "return_item" }) +@Entity({ tableName }) export default class ReturnItem { [OptionalProps]?: OptionalLineItemProps diff --git a/packages/modules/order/src/models/transaction.ts b/packages/modules/order/src/models/transaction.ts index 7544addd1d224..6210902b778df 100644 --- a/packages/modules/order/src/models/transaction.ts +++ b/packages/modules/order/src/models/transaction.ts @@ -24,55 +24,57 @@ import Return from "./return" type OptionalLineItemProps = DAL.ModelDateColumns +const tableName = "order_transaction" + const ReferenceIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_transaction", + tableName, columns: "reference_id", where: "deleted_at IS NOT NULL", }) const OrderIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_transaction", + tableName, columns: "order_id", where: "deleted_at IS NOT NULL", }) const ReturnIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_transaction", + tableName, columns: "return_id", where: "return_id IS NOT NULL AND deleted_at IS NOT NULL", }) const ExchangeIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_item", + tableName, columns: ["exchange_id"], where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL", }) const ClaimIdIndex = createPsqlIndexStatementHelper({ - tableName: "order_item", + tableName, columns: ["claim_id"], where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL", }) const CurrencyCodeIndex = createPsqlIndexStatementHelper({ - tableName: "order_transaction", + tableName, columns: "currency_code", where: "deleted_at IS NOT NULL", }) const DeletedAtIndex = createPsqlIndexStatementHelper({ - tableName: "order_transaction", + tableName, columns: "deleted_at", where: "deleted_at IS NOT NULL", }) const OrderIdVersionIndex = createPsqlIndexStatementHelper({ - tableName: "order_transaction", + tableName, columns: ["order_id", "version"], where: "deleted_at IS NOT NULL", }) -@Entity({ tableName: "order_transaction" }) +@Entity({ tableName }) @Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) @OrderIdVersionIndex.MikroORMIndex() export default class Transaction { From e960d38b88fb265298013664a34b72c9530a4bc2 Mon Sep 17 00:00:00 2001 From: Riqwan Thamir Date: Wed, 21 Aug 2024 19:20:44 +0200 Subject: [PATCH 2/4] feat(fulfillment,order): add created_by fields to fulfillment, return, claim, exchange --- packages/modules/fulfillment/package.json | 1 + .../.snapshot-medusa-fulfillment.json | 36 ++++++++++---- .../src/migrations/Migration20240821170957.ts | 47 +++++++++++++++++++ .../fulfillment/src/models/fulfillment.ts | 6 +++ .../migrations/.snapshot-medusa-order.json | 27 +++++++++++ .../src/migrations/Migration20240821170920.ts | 31 ++++++++++++ packages/modules/order/src/models/claim.ts | 3 ++ packages/modules/order/src/models/exchange.ts | 3 ++ packages/modules/order/src/models/return.ts | 3 ++ 9 files changed, 148 insertions(+), 9 deletions(-) create mode 100644 packages/modules/fulfillment/src/migrations/Migration20240821170957.ts create mode 100644 packages/modules/order/src/migrations/Migration20240821170920.ts diff --git a/packages/modules/fulfillment/package.json b/packages/modules/fulfillment/package.json index c473c4642b01e..ce99e42916d50 100644 --- a/packages/modules/fulfillment/package.json +++ b/packages/modules/fulfillment/package.json @@ -31,6 +31,7 @@ "migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create --initial -n InitialSetupMigration", "migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create", "migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:up", + "migration:down": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:down", "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear" }, "devDependencies": { diff --git a/packages/modules/fulfillment/src/migrations/.snapshot-medusa-fulfillment.json b/packages/modules/fulfillment/src/migrations/.snapshot-medusa-fulfillment.json index b530721865c6e..01970254492e7 100644 --- a/packages/modules/fulfillment/src/migrations/.snapshot-medusa-fulfillment.json +++ b/packages/modules/fulfillment/src/migrations/.snapshot-medusa-fulfillment.json @@ -874,7 +874,7 @@ "autoincrement": false, "primary": false, "nullable": false, - "default": "'calculated'", + "default": "'flat'", "enumItems": [ "calculated", "flat" @@ -899,8 +899,8 @@ "nullable": true, "mappedType": "text" }, - "fulfillment_provider_id": { - "name": "fulfillment_provider_id", + "provider_id": { + "name": "provider_id", "type": "text", "unsigned": false, "autoincrement": false, @@ -1001,14 +1001,14 @@ "expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_shipping_profile_id\" ON \"shipping_option\" (shipping_profile_id) WHERE deleted_at IS NULL" }, { - "keyName": "IDX_shipping_option_fulfillment_provider_id", + "keyName": "IDX_shipping_option_provider_id", "columnNames": [ - "fulfillment_provider_id" + "provider_id" ], "composite": false, "primary": false, "unique": false, - "expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_fulfillment_provider_id\" ON \"shipping_option\" (fulfillment_provider_id) WHERE deleted_at IS NULL" + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_shipping_option_provider_id\" ON \"shipping_option\" (provider_id) WHERE deleted_at IS NULL" }, { "keyName": "IDX_shipping_option_shipping_option_type_id", @@ -1068,10 +1068,10 @@ "deleteRule": "set null", "updateRule": "cascade" }, - "shipping_option_fulfillment_provider_id_foreign": { - "constraintName": "shipping_option_fulfillment_provider_id_foreign", + "shipping_option_provider_id_foreign": { + "constraintName": "shipping_option_provider_id_foreign", "columnNames": [ - "fulfillment_provider_id" + "provider_id" ], "localTableName": "public.shipping_option", "referencedColumnNames": [ @@ -1276,6 +1276,24 @@ "length": 6, "mappedType": "datetime" }, + "marked_shipped_by": { + "name": "marked_shipped_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, + "created_by": { + "name": "created_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, "delivered_at": { "name": "delivered_at", "type": "timestamptz", diff --git a/packages/modules/fulfillment/src/migrations/Migration20240821170957.ts b/packages/modules/fulfillment/src/migrations/Migration20240821170957.ts new file mode 100644 index 0000000000000..159d989c827b7 --- /dev/null +++ b/packages/modules/fulfillment/src/migrations/Migration20240821170957.ts @@ -0,0 +1,47 @@ +import { Migration } from "@mikro-orm/migrations" + +export class Migration20240821170957 extends Migration { + async up(): Promise { + this.addSql( + 'alter table if exists "shipping_option" drop constraint if exists "shipping_option_price_type_check";' + ) + + this.addSql( + 'alter table if exists "shipping_option" drop constraint if exists "shipping_option_fulfillment_provider_id_foreign";' + ) + + this.addSql( + 'alter table if exists "shipping_option" alter column "price_type" type text using ("price_type"::text);' + ) + this.addSql( + 'alter table if exists "shipping_option" add constraint "shipping_option_price_type_check" check ("price_type" in (\'calculated\', \'flat\'));' + ) + this.addSql( + 'alter table if exists "shipping_option" alter column "price_type" set default \'flat\';' + ) + this.addSql( + 'alter table if exists "fulfillment" add column if not exists "marked_shipped_by" text null, add column if not exists "created_by" text null;' + ) + } + + async down(): Promise { + this.addSql( + 'alter table if exists "shipping_option" drop constraint if exists "shipping_option_price_type_check";' + ) + this.addSql( + 'alter table if exists "shipping_option" alter column "price_type" type text using ("price_type"::text);' + ) + this.addSql( + 'alter table if exists "shipping_option" add constraint "shipping_option_price_type_check" check ("price_type" in (\'calculated\', \'flat\'));' + ) + this.addSql( + 'alter table if exists "shipping_option" alter column "price_type" set default \'calculated\';' + ) + this.addSql( + 'alter table if exists "fulfillment" drop column if exists "marked_shipped_by";' + ) + this.addSql( + 'alter table if exists "fulfillment" drop column if exists "created_by";' + ) + } +} diff --git a/packages/modules/fulfillment/src/models/fulfillment.ts b/packages/modules/fulfillment/src/models/fulfillment.ts index 3fb3ede218002..bd252b5035585 100644 --- a/packages/modules/fulfillment/src/models/fulfillment.ts +++ b/packages/modules/fulfillment/src/models/fulfillment.ts @@ -76,6 +76,12 @@ export default class Fulfillment { }) shipped_at: Date | null = null + @Property({ columnType: "text", nullable: true }) + marked_shipped_by: string | null = null + + @Property({ columnType: "text", nullable: true }) + created_by: string | null = null + @Property({ columnType: "timestamptz", nullable: true, diff --git a/packages/modules/order/src/migrations/.snapshot-medusa-order.json b/packages/modules/order/src/migrations/.snapshot-medusa-order.json index f96c32db2568c..2c9d08461a9a3 100644 --- a/packages/modules/order/src/migrations/.snapshot-medusa-order.json +++ b/packages/modules/order/src/migrations/.snapshot-medusa-order.json @@ -1600,6 +1600,15 @@ "nullable": true, "mappedType": "json" }, + "created_by": { + "name": "created_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, "metadata": { "name": "metadata", "type": "jsonb", @@ -1879,6 +1888,15 @@ "default": "false", "mappedType": "boolean" }, + "created_by": { + "name": "created_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, "metadata": { "name": "metadata", "type": "jsonb", @@ -2279,6 +2297,15 @@ "nullable": true, "mappedType": "json" }, + "created_by": { + "name": "created_by", + "type": "text", + "unsigned": false, + "autoincrement": false, + "primary": false, + "nullable": true, + "mappedType": "text" + }, "metadata": { "name": "metadata", "type": "jsonb", diff --git a/packages/modules/order/src/migrations/Migration20240821170920.ts b/packages/modules/order/src/migrations/Migration20240821170920.ts new file mode 100644 index 0000000000000..4342d52404832 --- /dev/null +++ b/packages/modules/order/src/migrations/Migration20240821170920.ts @@ -0,0 +1,31 @@ +import { Migration } from "@mikro-orm/migrations" + +export class Migration20240821170920 extends Migration { + async up(): Promise { + this.addSql( + 'alter table if exists "return" add column if not exists "created_by" text null;' + ) + + this.addSql( + 'alter table if exists "order_exchange" add column if not exists "created_by" text null;' + ) + + this.addSql( + 'alter table if exists "order_claim" add column if not exists "created_by" text null;' + ) + } + + async down(): Promise { + this.addSql( + 'alter table if exists "return" drop column if exists "created_by";' + ) + + this.addSql( + 'alter table if exists "order_exchange" drop column if exists "created_by";' + ) + + this.addSql( + 'alter table if exists "order_claim" drop column if exists "created_by";' + ) + } +} diff --git a/packages/modules/order/src/models/claim.ts b/packages/modules/order/src/models/claim.ts index d56dfc988ca13..5b0e4b630635e 100644 --- a/packages/modules/order/src/models/claim.ts +++ b/packages/modules/order/src/models/claim.ts @@ -137,6 +137,9 @@ export default class OrderClaim { }) transactions = new Collection(this) + @Property({ columnType: "text", nullable: true }) + created_by: string | null = null + @Property({ columnType: "jsonb", nullable: true }) metadata: Record | null = null diff --git a/packages/modules/order/src/models/exchange.ts b/packages/modules/order/src/models/exchange.ts index 87b16830949d0..a2deba86685c7 100644 --- a/packages/modules/order/src/models/exchange.ts +++ b/packages/modules/order/src/models/exchange.ts @@ -129,6 +129,9 @@ export default class OrderExchange { }) transactions = new Collection(this) + @Property({ columnType: "text", nullable: true }) + created_by: string | null = null + @Property({ columnType: "jsonb", nullable: true }) metadata: Record | null = null diff --git a/packages/modules/order/src/models/return.ts b/packages/modules/order/src/models/return.ts index 94f4d322b8c75..765e2ff40a391 100644 --- a/packages/modules/order/src/models/return.ts +++ b/packages/modules/order/src/models/return.ts @@ -150,6 +150,9 @@ export default class Return { }) transactions = new Collection(this) + @Property({ columnType: "text", nullable: true }) + created_by: string | null = null + @Property({ columnType: "jsonb", nullable: true }) metadata: Record | null = null From 9f35b01fe556df1a2a03212b5cf8ee0fe862923f Mon Sep 17 00:00:00 2001 From: Riqwan Thamir Date: Wed, 21 Aug 2024 19:25:33 +0200 Subject: [PATCH 3/4] chore: cleanup --- .../src/migrations/Migration20240821164505.ts | 34 +------------------ 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/packages/modules/order/src/migrations/Migration20240821164505.ts b/packages/modules/order/src/migrations/Migration20240821164505.ts index 720bfb9baad31..a069437a745a7 100644 --- a/packages/modules/order/src/migrations/Migration20240821164505.ts +++ b/packages/modules/order/src/migrations/Migration20240821164505.ts @@ -2,36 +2,30 @@ import { Migration } from "@mikro-orm/migrations" export class Migration20240821164505 extends Migration { async up(): Promise { - this.addSql('drop index if exists "IDX_order_deleted_at";') this.addSql( 'CREATE INDEX IF NOT EXISTS "IDX_order_item_deleted_at" ON "order_item" (deleted_at) WHERE deleted_at IS NOT NULL;' ) - this.addSql('drop index if exists "IDX_order_deleted_at";') this.addSql( 'CREATE INDEX IF NOT EXISTS "IDX_order_summary_deleted_at" ON "order_summary" (deleted_at) WHERE deleted_at IS NOT NULL;' ) - this.addSql('drop index if exists "IDX_order_claim_item_image_deleted_at";') this.addSql( 'CREATE INDEX IF NOT EXISTS "IDX_order_claim_item_deleted_at" ON "order_claim_item" (deleted_at) WHERE deleted_at IS NOT NULL;' ) - this.addSql('drop index if exists "IDX_order_claim_item_image_deleted_at";') this.addSql( 'CREATE INDEX IF NOT EXISTS "IDX_return_item_deleted_at" ON "return_item" (deleted_at) WHERE deleted_at IS NOT NULL;' ) - this.addSql('drop index if exists "IDX_order_deleted_at";') this.addSql( 'CREATE INDEX IF NOT EXISTS "IDX_order_shipping_deleted_at" ON "order_shipping" (deleted_at) WHERE deleted_at IS NOT NULL;' ) - this.addSql('drop index if exists "IDX_order_item_exchange_id";') - this.addSql('drop index if exists "IDX_order_item_claim_id";') this.addSql( '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 NOT NULL;' ) + this.addSql( '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 NOT NULL;' ) @@ -39,37 +33,11 @@ export class Migration20240821164505 extends Migration { async down(): Promise { this.addSql('drop index if exists "IDX_order_item_deleted_at";') - this.addSql( - 'CREATE INDEX IF NOT EXISTS "IDX_order_deleted_at" ON "order" (deleted_at) WHERE deleted_at IS NOT NULL;' - ) - this.addSql('drop index if exists "IDX_order_summary_deleted_at";') - this.addSql( - 'CREATE INDEX IF NOT EXISTS "IDX_order_deleted_at" ON "order" (deleted_at) WHERE deleted_at IS NOT NULL;' - ) - this.addSql('drop index if exists "IDX_order_claim_item_deleted_at";') - this.addSql( - '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;' - ) - this.addSql('drop index if exists "IDX_return_item_deleted_at";') - this.addSql( - '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;' - ) - this.addSql('drop index if exists "IDX_order_shipping_deleted_at";') - this.addSql( - 'CREATE INDEX IF NOT EXISTS "IDX_order_deleted_at" ON "order" (deleted_at) WHERE deleted_at IS NOT NULL;' - ) - this.addSql('drop index if exists "IDX_order_transaction_exchange_id";') this.addSql('drop index if exists "IDX_order_transaction_claim_id";') - this.addSql( - 'CREATE INDEX IF NOT EXISTS "IDX_order_item_exchange_id" ON "order_item" (exchange_id) WHERE exchange_id IS NOT NULL AND deleted_at IS NOT NULL;' - ) - this.addSql( - 'CREATE INDEX IF NOT EXISTS "IDX_order_item_claim_id" ON "order_item" (claim_id) WHERE claim_id IS NOT NULL AND deleted_at IS NOT NULL;' - ) } } From 0abd19ed34dfb5e4fdd807c4583a7a43ade0ad12 Mon Sep 17 00:00:00 2001 From: Riqwan Thamir Date: Wed, 21 Aug 2024 19:26:52 +0200 Subject: [PATCH 4/4] chore: remove package json changes --- packages/modules/fulfillment/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/modules/fulfillment/package.json b/packages/modules/fulfillment/package.json index ce99e42916d50..c473c4642b01e 100644 --- a/packages/modules/fulfillment/package.json +++ b/packages/modules/fulfillment/package.json @@ -31,7 +31,6 @@ "migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create --initial -n InitialSetupMigration", "migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create", "migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:up", - "migration:down": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:down", "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear" }, "devDependencies": {