Track SMS sent counts by type (mass, singular, auth, auto, admin).

Charge/refund bump the matching counter plus total; expose smsSentByType on business APIs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-09-09 11:31:17 +03:30
co-authored by Cursor
parent 717a203d48
commit a2dacfdc97
9 changed files with 156 additions and 22 deletions
@@ -0,0 +1,20 @@
-- Per-type lifetime SMS send counters (one unit = one recipient).
-- sms_sent_count remains the total across all types.
ALTER TABLE businesses
ADD COLUMN IF NOT EXISTS sms_sent_mass INTEGER NOT NULL DEFAULT 0,
ADD COLUMN IF NOT EXISTS sms_sent_singular INTEGER NOT NULL DEFAULT 0,
ADD COLUMN IF NOT EXISTS sms_sent_auth INTEGER NOT NULL DEFAULT 0,
ADD COLUMN IF NOT EXISTS sms_sent_auto_customer INTEGER NOT NULL DEFAULT 0,
ADD COLUMN IF NOT EXISTS sms_sent_admin INTEGER NOT NULL DEFAULT 0;
COMMENT ON COLUMN businesses.sms_sent_mass IS
'Lifetime bulk/mass customer SMS messages billed (one per recipient).';
COMMENT ON COLUMN businesses.sms_sent_singular IS
'Lifetime single-recipient SMS messages billed (customer one-to-one, partner public).';
COMMENT ON COLUMN businesses.sms_sent_auth IS
'Lifetime auth/OTP SMS messages billed.';
COMMENT ON COLUMN businesses.sms_sent_auto_customer IS
'Lifetime automatic customer SMS (birthdays, rewards, …) — reserved.';
COMMENT ON COLUMN businesses.sms_sent_admin IS
'Lifetime admin notification SMS (new order, visits, …) — reserved.';