From 58e20fa3fc266cbecc69b45998ef1fadd7056f9a Mon Sep 17 00:00:00 2001 From: Adrien de Peretti Date: Thu, 11 Sep 2025 11:54:12 +0200 Subject: [PATCH] chore(): Add missing product status index (#13475) **What** Add missing product status index --- .changeset/smooth-plants-switch.md | 5 +++++ .../src/migrations/.snapshot-medusa-product.json | 9 +++++++++ .../src/migrations/Migration20250911092221.ts | 13 +++++++++++++ packages/modules/product/src/models/product.ts | 6 ++++++ 4 files changed, 33 insertions(+) create mode 100644 .changeset/smooth-plants-switch.md create mode 100644 packages/modules/product/src/migrations/Migration20250911092221.ts diff --git a/.changeset/smooth-plants-switch.md b/.changeset/smooth-plants-switch.md new file mode 100644 index 0000000000..3dcafb2b68 --- /dev/null +++ b/.changeset/smooth-plants-switch.md @@ -0,0 +1,5 @@ +--- +"@medusajs/product": patch +--- + +chore(): Add missing product status index diff --git a/packages/modules/product/src/migrations/.snapshot-medusa-product.json b/packages/modules/product/src/migrations/.snapshot-medusa-product.json index 8e44625e1c..63f79f74f9 100644 --- a/packages/modules/product/src/migrations/.snapshot-medusa-product.json +++ b/packages/modules/product/src/migrations/.snapshot-medusa-product.json @@ -776,6 +776,15 @@ "unique": false, "expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_product_handle_unique\" ON \"product\" (handle) WHERE deleted_at IS NULL" }, + { + "keyName": "IDX_product_status", + "columnNames": [], + "composite": false, + "constraint": false, + "primary": false, + "unique": false, + "expression": "CREATE INDEX IF NOT EXISTS \"IDX_product_status\" ON \"product\" (status) WHERE deleted_at IS NULL" + }, { "keyName": "product_pkey", "columnNames": [ diff --git a/packages/modules/product/src/migrations/Migration20250911092221.ts b/packages/modules/product/src/migrations/Migration20250911092221.ts new file mode 100644 index 0000000000..26feb73e03 --- /dev/null +++ b/packages/modules/product/src/migrations/Migration20250911092221.ts @@ -0,0 +1,13 @@ +import { Migration } from '@mikro-orm/migrations'; + +export class Migration20250911092221 extends Migration { + + override async up(): Promise { + this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_product_status" ON "product" (status) WHERE deleted_at IS NULL;`); + } + + override async down(): Promise { + this.addSql(`drop index if exists "IDX_product_status";`); + } + +} diff --git a/packages/modules/product/src/models/product.ts b/packages/modules/product/src/models/product.ts index 9123390f2a..a9daced7c0 100644 --- a/packages/modules/product/src/models/product.ts +++ b/packages/modules/product/src/models/product.ts @@ -81,6 +81,12 @@ const Product = model unique: false, where: "deleted_at IS NULL", }, + { + name: "IDX_product_status", + on: ["status"], + unique: false, + where: "deleted_at IS NULL", + }, ]) export default Product