mirror of
https://ids-dev.idsbuybuybuy.com/ids-ecommerce/ids-svc-product.git
synced 2026-11-29 16:57:41 +08:00
feat: add priority column to product_category and update related indexes
This commit is contained in:
parent
791e09b35b
commit
6074355b39
@ -529,8 +529,11 @@ CREATE TABLE IF NOT EXISTS product.product_category (
|
||||
);
|
||||
|
||||
-- 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.
|
||||
-- service version. Add columns required by indexes / newer code before use.
|
||||
ALTER TABLE product.product_category
|
||||
ADD COLUMN IF NOT EXISTS priority INTEGER NOT NULL DEFAULT 0;
|
||||
-- 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);
|
||||
@ -539,6 +542,8 @@ 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;
|
||||
CREATE INDEX IF NOT EXISTS idx_product_category_active_status_parent_priority
|
||||
ON product.product_category (status, parent_id, priority, id) WHERE deleted_at IS NULL;
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uq_product_category_active_platform_category
|
||||
ON product.product_category (platform_category_id) WHERE deleted_at IS NULL;
|
||||
CREATE INDEX IF NOT EXISTS idx_product_category_active_platform_parent_category
|
||||
|
||||
@ -205,6 +205,11 @@ COMMENT ON COLUMN product.product_category.platform_parent_category_id IS '外
|
||||
COMMENT ON COLUMN product.product_category.has_children IS '上游声明的是否存在下级类目,不以本地直接子节点数量推断';
|
||||
COMMENT ON COLUMN product.product_category.deleted_at IS '软删除时间;NULL 表示未删除';
|
||||
|
||||
-- Older installs may already have product_category without priority;
|
||||
-- CREATE TABLE IF NOT EXISTS will not add it.
|
||||
ALTER TABLE product.product_category
|
||||
ADD COLUMN IF NOT EXISTS priority INTEGER NOT NULL DEFAULT 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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user