From 9567b967b2e616bc2dd28e73b8c48ea1a9e9b8fb Mon Sep 17 00:00:00 2001 From: BXY <103352887+BXY0414@users.noreply.github.com> Date: Thu, 8 Oct 2026 15:06:22 +0800 Subject: [PATCH] feat: add index for active product categories by parent and name --- internal/repository/product_repository.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/repository/product_repository.go b/internal/repository/product_repository.go index f3675ee..9c7f7f6 100644 --- a/internal/repository/product_repository.go +++ b/internal/repository/product_repository.go @@ -426,7 +426,8 @@ CREATE TABLE IF NOT EXISTS product.product_category ( updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), deleted_at TIMESTAMPTZ ); -CREATE UNIQUE INDEX IF NOT EXISTS uq_product_category_active_parent_name + +CREATE INDEX IF NOT EXISTS idx_product_category_active_parent_name ON product.product_category (COALESCE(parent_id, 0), lower(btrim(name))) WHERE deleted_at IS NULL; CREATE INDEX IF NOT EXISTS idx_product_category_active_parent_priority ON product.product_category (parent_id, priority, id) WHERE deleted_at IS NULL;