← back to Dw Validator Debug TK11314
auto-data-snapshot: 2026-08-22T11:52:06 (1 data files) — DW-Agents/vendor-command-center/cost-backfill-2026-08-22-APPLY.sql
7538e9d01a3db2af84cd3ff9e29b86fca45e5e70 · 2026-08-22 11:52:18 -0700 · auto-commit-fleet
Files touched
A DW-Agents/vendor-command-center/cost-backfill-2026-08-22-APPLY.sql
Diff
commit 7538e9d01a3db2af84cd3ff9e29b86fca45e5e70
Author: auto-commit-fleet <steve@designerwallcoverings.com>
Date: Sat Aug 22 11:52:18 2026 -0700
auto-data-snapshot: 2026-08-22T11:52:06 (1 data files) — DW-Agents/vendor-command-center/cost-backfill-2026-08-22-APPLY.sql
---
.../cost-backfill-2026-08-22-APPLY.sql | 36 ++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/DW-Agents/vendor-command-center/cost-backfill-2026-08-22-APPLY.sql b/DW-Agents/vendor-command-center/cost-backfill-2026-08-22-APPLY.sql
new file mode 100644
index 00000000..4be27638
--- /dev/null
+++ b/DW-Agents/vendor-command-center/cost-backfill-2026-08-22-APPLY.sql
@@ -0,0 +1,36 @@
+-- COMMITTED apply version of cost-backfill-2026-08-22.sql — run by Steve.
+-- Target: whichever DB psql points at. For Victor visibility -> Mac2 mirror
+-- (PGHOST=/tmp). For durable/canonical -> run on Kamatera then re-sync.
+BEGIN;
+DROP TABLE IF EXISTS cost_backfill_restore_20260822;
+CREATE TABLE cost_backfill_restore_20260822 AS
+SELECT shopify_id, cost_price AS old_cost_price, cost_source AS old_cost_source
+FROM shopify_products WHERE status='ACTIVE' AND (cost_price IS NULL OR cost_price::numeric=0);
+
+WITH ka AS (SELECT upper(regexp_replace(mfr_sku::text,'[^A-Za-z0-9]','','g')) k, max(new_whls) whls
+ FROM kravet_authoritative_pricing WHERE new_whls IS NOT NULL AND new_whls>0 GROUP BY 1)
+UPDATE shopify_products sp
+SET cost_price=ka.whls, cost_source='kravet_authoritative_pricing.new_whls backfill 2026-08-22'
+FROM ka WHERE sp.status='ACTIVE' AND (sp.cost_price IS NULL OR sp.cost_price::numeric=0)
+ AND ka.k=upper(regexp_replace(sp.mfr_sku::text,'[^A-Za-z0-9]','','g'))
+ -- Cody-gate 2026-08-22: allow-list to Kravet/Cowtan family ONLY (excludes ~81
+ -- coincidental non-family normalized matches: Phillipe Romano, Caroline Cecil, etc.)
+ AND sp.vendor ILIKE ANY(ARRAY['%kravet%','%lee jofa%','%brunschwig%','%baker%','%groundworks%',
+ '%cole%son%','%clarke%clarke%','%clarke and clarke%','%mulberry%','%threads%','%andrew martin%',
+ '%gaston%daniela%','%donghia%','%anna french%','%cowtan%','%colefax%','%nicolette%','%aerin%',
+ '%barclay%','%thom filicia%','%winfield thybony%']);
+
+WITH jd AS (SELECT upper(regexp_replace(mfr_sku::text,'[^A-Za-z0-9]','','g')) k, max(our_cost_yd) cost
+ FROM justin_david_pricing_2026 WHERE our_cost_yd IS NOT NULL AND our_cost_yd>0 GROUP BY 1)
+UPDATE shopify_products sp
+SET cost_price=jd.cost, cost_source='justin_david_pricing_2026.our_cost_yd backfill 2026-08-22'
+FROM jd WHERE sp.status='ACTIVE' AND (sp.cost_price IS NULL OR sp.cost_price::numeric=0)
+ AND jd.k=upper(regexp_replace(sp.mfr_sku::text,'[^A-Za-z0-9]','','g'));
+
+SELECT count(*) FILTER (WHERE cost_source LIKE '%backfill 2026-08-22%') AS total_backfilled,
+ round(100.0*count(*) FILTER (WHERE cost_price IS NOT NULL AND cost_price::numeric>0)/count(*),1) AS pct_with_cost
+FROM shopify_products WHERE status='ACTIVE';
+COMMIT;
+
+-- REVERT: UPDATE shopify_products sp SET cost_price=r.old_cost_price, cost_source=r.old_cost_source
+-- FROM cost_backfill_restore_20260822 r WHERE sp.shopify_id=r.shopify_id;
← ddbc12bc auto-data-snapshot: 2026-08-22T11:19:22 (1 data files) — DW-
·
back to Dw Validator Debug TK11314
·
auto-data-snapshot: 2026-08-23T01:39:39 (2 data files) — sho 3c71b3b8 →