| 37804 |
amit |
1 |
-- 2026-09-28 - store every GSTIN in fofo.fofo_store in upper case.
|
|
|
2 |
--
|
|
|
3 |
-- A GSTIN is upper case by definition. Four rows were not: 06bmlpk3545g1z0 (HRMS007),
|
|
|
4 |
-- 03AAccn9802g1zp (T-UPSKN1434, our own registration on a real store) and two junk test values on
|
|
|
5 |
-- T-UPKND1433 / T-UPSRV1439. All four stores are inactive. They predate the normalisation that
|
|
|
6 |
-- RetailerServiceImpl.validateGstNumbers applies (r37669, live 2026-09-21), and that only covers the
|
|
|
7 |
-- partner-update path - the LOI and trial-form paths write the field directly.
|
|
|
8 |
--
|
|
|
9 |
-- The code side is fixed at the mutation site: FofoStore.setGstNumber now normalises, so no write
|
|
|
10 |
-- path can store mixed case again. This script corrects the rows already on record.
|
|
|
11 |
--
|
|
|
12 |
-- Case matters downstream: NIC expects upper case, and any comparison that is not case-insensitive
|
|
|
13 |
-- silently fails to match - including the "is this our own seller GSTIN" check that decides whether
|
|
|
14 |
-- a NIC refusal is about the buyer or about us.
|
|
|
15 |
--
|
|
|
16 |
-- NOT APPLIED automatically. Affects 4 rows. dtr.retailer.number has 34 mixed-case values and is
|
|
|
17 |
-- deliberately NOT touched here - out of scope, raise separately.
|
|
|
18 |
|
|
|
19 |
CREATE TABLE IF NOT EXISTS fofo.fofo_store_gst_case_bak_20260928 (
|
|
|
20 |
id INT NOT NULL,
|
|
|
21 |
gst_number VARCHAR(50) NULL,
|
|
|
22 |
backed_up_at DATETIME NOT NULL,
|
|
|
23 |
PRIMARY KEY (id)
|
|
|
24 |
) ENGINE = InnoDB DEFAULT CHARSET = utf8;
|
|
|
25 |
|
|
|
26 |
INSERT INTO fofo.fofo_store_gst_case_bak_20260928 (id, gst_number, backed_up_at)
|
|
|
27 |
SELECT id, gst_number, NOW() FROM fofo.fofo_store
|
|
|
28 |
WHERE gst_number IS NOT NULL AND gst_number <> ''
|
|
|
29 |
AND CAST(gst_number AS BINARY) <> CAST(UPPER(gst_number) AS BINARY);
|
|
|
30 |
|
|
|
31 |
UPDATE fofo.fofo_store
|
|
|
32 |
SET gst_number = UPPER(gst_number)
|
|
|
33 |
WHERE gst_number IS NOT NULL AND gst_number <> ''
|
|
|
34 |
AND CAST(gst_number AS BINARY) <> CAST(UPPER(gst_number) AS BINARY);
|
|
|
35 |
|
|
|
36 |
-- Verify: expect 0 remaining, and the backup holding what was changed.
|
|
|
37 |
-- SELECT COUNT(*) FROM fofo.fofo_store
|
|
|
38 |
-- WHERE gst_number <> '' AND CAST(gst_number AS BINARY) <> CAST(UPPER(gst_number) AS BINARY);
|
|
|
39 |
-- SELECT * FROM fofo.fofo_store_gst_case_bak_20260928;
|
|
|
40 |
--
|
|
|
41 |
-- Rollback, if ever needed:
|
|
|
42 |
-- UPDATE fofo.fofo_store s JOIN fofo.fofo_store_gst_case_bak_20260928 b ON b.id = s.id
|
|
|
43 |
-- SET s.gst_number = b.gst_number;
|