feat: add platform category ID and parent category ID columns to product_category table

This commit is contained in:
BXY 2026-10-09 09:25:38 +08:00
parent e70510682a
commit 339558075e

View File

@ -439,6 +439,13 @@ CREATE TABLE IF NOT EXISTS product.product_category (
deleted_at TIMESTAMPTZ 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 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; 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 CREATE INDEX IF NOT EXISTS idx_product_category_active_parent_priority