diff --git a/.changeset/empty-brooms-unite.md b/.changeset/empty-brooms-unite.md new file mode 100644 index 0000000000..ba936909b8 --- /dev/null +++ b/.changeset/empty-brooms-unite.md @@ -0,0 +1,5 @@ +--- +"@medusajs/promotion": patch +--- + +Add metadata support in the promotion model. diff --git a/packages/modules/promotion/src/migrations/.snapshot-medusa-promotion.json b/packages/modules/promotion/src/migrations/.snapshot-medusa-promotion.json index 3077698417..0ff8e91727 100644 --- a/packages/modules/promotion/src/migrations/.snapshot-medusa-promotion.json +++ b/packages/modules/promotion/src/migrations/.snapshot-medusa-promotion.json @@ -530,6 +530,15 @@ "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", diff --git a/packages/modules/promotion/src/migrations/Migration20251107050148.ts b/packages/modules/promotion/src/migrations/Migration20251107050148.ts new file mode 100644 index 0000000000..c1d35f67b7 --- /dev/null +++ b/packages/modules/promotion/src/migrations/Migration20251107050148.ts @@ -0,0 +1,13 @@ +import { Migration } from '@mikro-orm/migrations'; + +export class Migration20251107050148 extends Migration { + + override async up(): Promise { + this.addSql(`alter table if exists "promotion" add column if not exists "metadata" jsonb null;`); + } + + override async down(): Promise { + this.addSql(`alter table if exists "promotion" drop column if exists "metadata";`); + } + +} diff --git a/packages/modules/promotion/src/models/promotion.ts b/packages/modules/promotion/src/models/promotion.ts index 60dee90f4a..bdcb9010fc 100644 --- a/packages/modules/promotion/src/models/promotion.ts +++ b/packages/modules/promotion/src/models/promotion.ts @@ -28,6 +28,7 @@ const Promotion = model pivotTable: "promotion_promotion_rule", mappedBy: "promotions", }), + metadata: model.json().nullable(), }) .cascades({ delete: ["application_method"],