Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
37578 amit 1
-- One web offer per model: the badge is keyed on its consolidated CONTENT, not on a
2
-- circular row.
3
--
4
-- Before: one web_offer per circular row, so a model appeared in as many badges as the
5
-- circular had rows naming it - Edge 60 Pro 12+256 carried five. A partner's product card
6
-- listed all five and had to reconcile them.
7
--
8
-- After: every model's offers are consolidated into one description, and models whose
9
-- consolidated terms are IDENTICAL share a single web_offer. Sep'26: 191 badges -> 107,
10
-- covering the same 314 models, each appearing exactly once.
11
--
12
-- circular_page_no / circular_row_no stay for reference but no longer identify a badge -
13
-- one badge now spans many rows. They are left NULL for content-keyed rows, and MySQL
14
-- permits repeated NULLs in uk_circular_row, so the old key does not fight the new one.
15
 
16
ALTER TABLE dtr.web_offer
17
  -- sha256 over the normalised content: modes, values, banks, timing, schemes, tenures,
18
  -- windows. Two models with the same terms hash the same and share the badge.
19
  ADD COLUMN circular_offer_key CHAR(64) NULL,
20
  ADD UNIQUE KEY uk_circular_offer_key (circular_document_id, circular_offer_key);
21
 
22
-- The old row-keyed badges cannot be migrated: one of them is a fragment of what a
23
-- content-keyed badge now says, and there is no mapping from five fragments to one whole.
24
-- They are regenerated in full by the next ingest.
25
--
26
-- ⚠️ web_offer_product has NO foreign key to web_offer, so its rows do NOT cascade and
27
-- must be cleared first or they are orphaned. web_offer_sync_shadow DOES cascade.
28
--
29
-- source='CIRCULAR' only. The 3,850 hand-authored MANUAL rows are never touched.
30
DELETE FROM dtr.web_offer_product
31
 WHERE webOfferId IN (SELECT id FROM dtr.web_offer WHERE source = 'CIRCULAR');
32
 
33
DELETE FROM dtr.web_offer WHERE source = 'CIRCULAR';