-- ClientFlow v4 migration 003: separated external product codes.
ALTER TABLE products ADD COLUMN IF NOT EXISTS jasmin_sales_item TEXT;
ALTER TABLE opportunity_items ADD COLUMN IF NOT EXISTS jasmin_sales_item TEXT;
ALTER TABLE order_items ADD COLUMN IF NOT EXISTS jasmin_sales_item TEXT;

CREATE INDEX IF NOT EXISTS idx_products_jasmin_sales_item
ON products(jasmin_sales_item)
WHERE jasmin_sales_item IS NOT NULL AND jasmin_sales_item <> '';

CREATE INDEX IF NOT EXISTS idx_opportunity_items_jasmin_sales_item
ON opportunity_items(jasmin_sales_item)
WHERE jasmin_sales_item IS NOT NULL AND jasmin_sales_item <> '';
