diff --git a/packages/modules/fulfillment/src/migrations/.snapshot-medusa-fulfillment.json b/packages/modules/fulfillment/src/migrations/.snapshot-medusa-fulfillment.json index b530721865..0197025449 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 0000000000..159d989c82 --- /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 3fb3ede218..bd252b5035 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 f96c32db25..2c9d08461a 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 0000000000..4342d52404 --- /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 d56dfc988c..5b0e4b6306 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 87b1683094..a2deba8668 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 94f4d322b8..765e2ff40a 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