Skip to content

Commit ef15868

Browse files
juanzgcfPolic
andauthored
feat(promotion): Add metadata column to promotion (#13999)
* feat(promotion): Add metadata column to promotion Add metadata column to the promotion model. Closes CORE-1276 * Add changeset --------- Co-authored-by: Frane Polić <[email protected]>
1 parent 1ea932a commit ef15868

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

.changeset/empty-brooms-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/promotion": patch
3+
---
4+
5+
Add metadata support in the promotion model.

packages/modules/promotion/src/migrations/.snapshot-medusa-promotion.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,15 @@
530530
"nullable": true,
531531
"mappedType": "text"
532532
},
533+
"metadata": {
534+
"name": "metadata",
535+
"type": "jsonb",
536+
"unsigned": false,
537+
"autoincrement": false,
538+
"primary": false,
539+
"nullable": true,
540+
"mappedType": "json"
541+
},
533542
"created_at": {
534543
"name": "created_at",
535544
"type": "timestamptz",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Migration } from '@mikro-orm/migrations';
2+
3+
export class Migration20251107050148 extends Migration {
4+
5+
override async up(): Promise<void> {
6+
this.addSql(`alter table if exists "promotion" add column if not exists "metadata" jsonb null;`);
7+
}
8+
9+
override async down(): Promise<void> {
10+
this.addSql(`alter table if exists "promotion" drop column if exists "metadata";`);
11+
}
12+
13+
}

packages/modules/promotion/src/models/promotion.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const Promotion = model
2828
pivotTable: "promotion_promotion_rule",
2929
mappedBy: "promotions",
3030
}),
31+
metadata: model.json().nullable(),
3132
})
3233
.cascades({
3334
delete: ["application_method"],

0 commit comments

Comments
 (0)