From ef15868ca8b309dc902470b2da0096255da82c5d Mon Sep 17 00:00:00 2001 From: juanzgc Date: Mon, 17 Nov 2025 13:50:57 -0500 Subject: [PATCH] feat(promotion): Add metadata column to promotion (#13999) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(promotion): Add metadata column to promotion Add metadata column to the promotion model. Closes CORE-1276 * Add changeset --------- Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com> --- .changeset/empty-brooms-unite.md | 5 +++++ .../src/migrations/.snapshot-medusa-promotion.json | 9 +++++++++ .../src/migrations/Migration20251107050148.ts | 13 +++++++++++++ packages/modules/promotion/src/models/promotion.ts | 1 + 4 files changed, 28 insertions(+) create mode 100644 .changeset/empty-brooms-unite.md create mode 100644 packages/modules/promotion/src/migrations/Migration20251107050148.ts 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"],