fix(index): index enum fields (#13428)

https://github.com/medusajs/medusa/issues/13372

What:
 - It handles enum fields corretly when added to filterable fields
This commit is contained in:
Carlos R. L. Rodrigues
2025-09-07 10:39:58 -03:00
committed by GitHub
parent 637d4cf7ef
commit 71d8a0031f
6 changed files with 57 additions and 6 deletions

View File

@@ -12,7 +12,7 @@ const link =
},
{
linkable: BrandModule.linkable.brand.id,
filterable: ["id", "name"],
filterable: ["id", "name", "status"],
isList: false,
}
)

View File

@@ -3,7 +3,7 @@ import { Migration } from "@mikro-orm/migrations"
export class Migration20250805184935 extends Migration {
override async up(): Promise<void> {
this.addSql(
`create table if not exists "brand" ("id" text not null, "name" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "brand_pkey" primary key ("id"));`
`create table if not exists "brand" ("id" text not null, "name" text not null, "status" text default 'active', "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "brand_pkey" primary key ("id"));`
)
this.addSql(
`CREATE INDEX IF NOT EXISTS "IDX_brand_deleted_at" ON "brand" (deleted_at) WHERE deleted_at IS NULL;`

View File

@@ -3,4 +3,5 @@ import { model } from "@medusajs/utils"
export const Brand = model.define("brand", {
id: model.id({ prefix: "brand" }).primaryKey(),
name: model.text(),
status: model.enum(["active", "inactive"]).default("active"),
})