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..a069437a745a7 --- /dev/null +++ b/packages/modules/order/src/migrations/Migration20240821164505.ts @@ -0,0 +1,43 @@ +import { Migration } from "@mikro-orm/migrations" + +export class Migration20240821164505 extends Migration { + async up(): Promise { + 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( + 'CREATE INDEX IF NOT EXISTS "IDX_order_summary_deleted_at" ON "order_summary" (deleted_at) WHERE deleted_at IS NOT NULL;' + ) + + 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( + 'CREATE INDEX IF NOT EXISTS "IDX_return_item_deleted_at" ON "return_item" (deleted_at) WHERE deleted_at IS NOT NULL;' + ) + + 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( + '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('drop index if exists "IDX_order_summary_deleted_at";') + this.addSql('drop index if exists "IDX_order_claim_item_deleted_at";') + this.addSql('drop index if exists "IDX_return_item_deleted_at";') + this.addSql('drop index if exists "IDX_order_shipping_deleted_at";') + this.addSql('drop index if exists "IDX_order_transaction_exchange_id";') + this.addSql('drop index if exists "IDX_order_transaction_claim_id";') + } +} 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 {