ids-svc-product/scripts/sql/migrate-product-groups-and-category-properties.sql

16 lines
620 B
SQL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Adds category property storage and allows group names to repeat under
-- different parents. Run this migration before deploying the application.
ALTER TABLE product.products
ADD COLUMN IF NOT EXISTS category_properties JSONB NOT NULL DEFAULT '{}'::JSONB;
DROP INDEX IF EXISTS product.uq_product_category_group_normalized_name;
CREATE UNIQUE INDEX IF NOT EXISTS uq_product_category_group_normalized_name
ON product.catalog_category (
store_id,
COALESCE(parent_id, 0),
lower(btrim(regexp_replace(translate(name, ' ', ' '), '[[:space:]]+', ' ', 'g')))
)
WHERE node_type = 2;