From 339558075ee8d749b993ce944ed870ad1a1f135b Mon Sep 17 00:00:00 2001 From: BXY <103352887+BXY0414@users.noreply.github.com> Date: Fri, 9 Oct 2026 09:25:38 +0800 Subject: [PATCH] feat: add platform category ID and parent category ID columns to product_category table --- internal/repository/product_repository.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/repository/product_repository.go b/internal/repository/product_repository.go index cd126d0..b47c218 100644 --- a/internal/repository/product_repository.go +++ b/internal/repository/product_repository.go @@ -439,6 +439,13 @@ CREATE TABLE IF NOT EXISTS product.product_category ( deleted_at TIMESTAMPTZ ); +-- CREATE TABLE IF NOT EXISTS does not alter a table created by an earlier +-- service version. The taxonomy is rebuilt before this version is deployed, +-- so these mandatory source columns can be added without a legacy backfill. +ALTER TABLE product.product_category + ADD COLUMN IF NOT EXISTS platform_category_id BIGINT NOT NULL CHECK (platform_category_id > 0), + ADD COLUMN IF NOT EXISTS platform_parent_category_id BIGINT NOT NULL CHECK (platform_parent_category_id >= 0); + 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