mirror of
https://ids-dev.idsbuybuybuy.com/ids-ecommerce/ids-svc-product.git
synced 2026-11-29 16:57:41 +08:00
18 lines
1018 B
SQL
18 lines
1018 B
SQL
-- One-time migration for optional SPU codes and non-unique SKU business codes.
|
|
-- Run during a maintenance window before deploying the corresponding service code.
|
|
-- CREATE/DROP INDEX CONCURRENTLY must not be wrapped in a transaction.
|
|
|
|
-- Empty SPU codes are allowed multiple times in one store. Non-empty active
|
|
-- product codes remain unique within their store.
|
|
DROP INDEX CONCURRENTLY IF EXISTS product.uq_products_spu_no;
|
|
DROP INDEX CONCURRENTLY IF EXISTS product.uq_products_store_spu_no;
|
|
CREATE UNIQUE INDEX CONCURRENTLY uq_products_store_spu_no
|
|
ON product.products (store_id, spu_no)
|
|
WHERE deleted_at IS NULL AND spu_no <> '';
|
|
|
|
-- SKU business codes are not identifiers and may repeat, including among
|
|
-- active SKUs in the same store. SKU primary keys remain the stable identity.
|
|
DROP INDEX CONCURRENTLY IF EXISTS product.uq_product_items_sku_no;
|
|
DROP INDEX CONCURRENTLY IF EXISTS product.uq_product_items_sku_no_active;
|
|
DROP INDEX CONCURRENTLY IF EXISTS product.uq_product_items_store_sku_no_active;
|