ids-svc-product/scripts/sql/add-product-item-supply-price.sql

15 lines
597 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Adds the nullable SKU supply price without modifying historical values.
-- Amounts are stored in cents; NULL means the supply price has not been maintained.
ALTER TABLE product.product_items
ADD COLUMN IF NOT EXISTS supply_price BIGINT;
ALTER TABLE product.product_items
DROP CONSTRAINT IF EXISTS chk_product_items_supply_price;
ALTER TABLE product.product_items
ADD CONSTRAINT chk_product_items_supply_price
CHECK (supply_price IS NULL OR supply_price >= 0);
COMMENT ON COLUMN product.product_items.supply_price
IS 'SKU 供货价,单位:分;NULL 表示未维护';