← back to Mfr Recovery 2026 08 23

novasuede_mfr_recovery_dryrun.sql

26 lines

-- DRY RUN: Novasuede mfr_sku recovery via handle-strip→novasuede_catalog join
-- Ticket: TK-10677 (sub-work of TK-10794)
-- Recovers 14 of 22 ACTIVE Novasuede products with null mfr_sku via LOCAL JOIN
-- The other 8 (sand, spice, abyss, flame, gentle-pine, satin, umber-copy, sand-duplicate) 
--   are not in the catalog - need live scrape or manual entry
-- Reversible: undo = UPDATE shopify_products SET mfr_sku='' WHERE id IN (<these 14 ids>)
-- Blast radius: 14 rows

BEGIN;

WITH stripped AS (
  SELECT 
    id,
    regexp_replace(handle, '-luxury-suede.*|(-fabric-wallcovering)', '', 'g') as stripped_handle
  FROM shopify_products 
  WHERE vendor = 'Novasuede'
    AND status = 'ACTIVE'
    AND (mfr_sku IS NULL OR mfr_sku = '')
)
SELECT sp.id, sp.title, s.stripped_handle, nc.mfr_sku as new_mfr_sku, nc.dw_sku as staging_dw_sku
FROM shopify_products sp
JOIN stripped s ON s.id = sp.id
JOIN novasuede_catalog nc ON nc.mfr_sku = s.stripped_handle;

ROLLBACK;