Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

-- Retire the SENDGRID sender label from dtr.mail_outbox.
--
-- SENDGRID never meant SendGrid. MailOutboxService.resolveSender() routed it to
-- the Google Workspace relay, same as RELAY -- which is why outbox mail kept
-- being delivered while code that injected a JavaMailSender directly failed
-- against the real (and dead) SendGrid bean.
--
-- Relabelling therefore changes no behaviour: these rows were already being sent
-- through the relay. It removes a label that named a provider we do not use.
--
-- APPLIED TO PRODUCTION (hadb1) 2026-08-31 18:10 IST.
--   before: SENDGRID=5956  RELAY=0     GOOGLE=4896  (total 10852)
--   after:  SENDGRID=0     RELAY=5956  GOOGLE=4896  (total 10852)
--   backup: dtr.mail_outbox_sendgrid_backup_20260831_1810 (5956 rows)
--
-- The single PENDING row (id=26838) migrated cleanly and still routes to the
-- relay, exactly as it would have before.

-- 1. Back up what is about to change.
CREATE TABLE dtr.mail_outbox_sendgrid_backup_20260831_1810 AS
SELECT id, sender_type, status, created_at
FROM dtr.mail_outbox
WHERE sender_type = 'SENDGRID';

-- 2. Relabel.
UPDATE dtr.mail_outbox
SET sender_type = 'RELAY'
WHERE sender_type = 'SENDGRID';

-- 3. Verify: expect SENDGRID=0 and only GOOGLE,RELAY remaining.
SELECT sender_type, COUNT(*) FROM dtr.mail_outbox GROUP BY sender_type;

-- Rollback, should it ever be needed:
--   UPDATE dtr.mail_outbox o
--     JOIN dtr.mail_outbox_sendgrid_backup_20260831_1810 b ON b.id = o.id
--     SET o.sender_type = b.sender_type;