| Line 1... |
Line 1... |
| 1 |
-- Migration: Backfill GST numbers from user.counter to fofo.fofo_store
|
1 |
-- Migration: Backfill GST numbers from user.counter to fofo.fofo_store
|
| 2 |
-- Purpose: fofo_store.gst_number is now the canonical source for partner GST.
|
2 |
-- Purpose: fofo_store.gst_number is now the canonical source for partner GST.
|
| 3 |
-- This script copies existing valid GST numbers from the counter table.
|
3 |
-- This script copies existing valid GST numbers from the counter table.
|
| 4 |
-- Safety: Non-destructive. Old counter data is NOT modified or deleted.
|
4 |
-- Safety: Non-destructive. Old counter data is NOT modified or deleted.
|
| - |
|
5 |
|
| 5 |
-- Prerequisite: fofo.fofo_store.gst_number column already exists.
|
6 |
-- Step 0: Add gst_number column if it doesn't exist
|
| - |
|
7 |
ALTER TABLE fofo.fofo_store ADD COLUMN IF NOT EXISTS gst_number VARCHAR(15) DEFAULT NULL;
|
| 6 |
|
8 |
|
| 7 |
-- Step 1: Verify data before migration (dry run)
|
9 |
-- Step 1: Verify data before migration (dry run)
|
| 8 |
SELECT fs.id, fs.code, fs.gst_number AS current_fofo_gst, c.gstin AS counter_gst
|
10 |
SELECT fs.id, fs.code, fs.gst_number AS current_fofo_gst, c.gstin AS counter_gst
|
| 9 |
FROM fofo.fofo_store fs
|
11 |
FROM fofo.fofo_store fs
|
| 10 |
JOIN user.privatedealuser pdu ON pdu.id = fs.id
|
12 |
JOIN user.privatedealuser pdu ON pdu.id = fs.id
|