-- 023_fcc_rmd_removed.sql
-- FCC carriers removed from the Robocall Mitigation Database for noncompliance.
-- Sources: FCC DA-26-282 (Mar 2026), DA-26-237 (Mar 2026 Belthrough FDO),
--          39 FCC Rcd 1319 (Feb 2024 Viettel 12), 40 FCC Rcd 6009 (Aug 2025 mass removal)

BEGIN;

CREATE TABLE IF NOT EXISTS fcc_rmd_removed (
    id                      SERIAL PRIMARY KEY,
    -- Identifying info
    rmd_number              TEXT,                          -- RMD file number if known (e.g. RMD0007602)
    frn                     TEXT,                          -- FCC Registration Number if known
    business_name           TEXT NOT NULL,
    business_address        TEXT,
    -- Removal action details
    action_type             TEXT NOT NULL CHECK (action_type IN (
                                'final_determination_order',   -- FDO: originating illegal robocalls
                                'deficiency_removal',          -- Removed for deficient/incomplete certification
                                'show_cause_pending'           -- Show cause issued, removal imminent
                            )),
    fcc_document            TEXT,                          -- DA number (e.g. DA-26-237)
    fcc_docket              TEXT,                          -- EB docket (e.g. EB-TCD-25-00038590)
    fcc_citation            TEXT,                          -- FCC Rcd citation
    action_date             DATE,                          -- Date of FCC order
    deficiency_notice_date  DATE,                          -- Date deficiency was first noticed
    removal_reason          TEXT,                          -- Human-readable reason
    -- Contact info (from FCC order or independently researched)
    contact_name            TEXT,
    contact_email           TEXT,
    contact_phone           TEXT,
    company_website         TEXT,
    -- Research status
    email_researched        BOOLEAN DEFAULT FALSE,
    email_research_notes    TEXT,
    -- Mautic tracking
    mautic_lead_id          INTEGER,
    -- Timestamps
    created_at              TIMESTAMPTZ DEFAULT now(),
    updated_at              TIMESTAMPTZ DEFAULT now()
);

CREATE INDEX IF NOT EXISTS idx_rmd_removed_rmd_number   ON fcc_rmd_removed(rmd_number);
CREATE INDEX IF NOT EXISTS idx_rmd_removed_business     ON fcc_rmd_removed(business_name);
CREATE INDEX IF NOT EXISTS idx_rmd_removed_action_type  ON fcc_rmd_removed(action_type);
CREATE INDEX IF NOT EXISTS idx_rmd_removed_action_date  ON fcc_rmd_removed(action_date);
CREATE INDEX IF NOT EXISTS idx_rmd_removed_email        ON fcc_rmd_removed(contact_email);
CREATE INDEX IF NOT EXISTS idx_rmd_removed_no_email     ON fcc_rmd_removed(id) WHERE contact_email IS NULL;

-- ============================================================
-- SEED DATA
-- ============================================================

-- ------------------------------------------------------------
-- 1. BELTHROUGH LLC — Final Determination Order (DA 26-237)
--    March 12, 2026 — Originating illegal robocalls
--    Contact email from FCC order document
-- ------------------------------------------------------------
INSERT INTO fcc_rmd_removed (
    rmd_number, business_name, business_address,
    action_type, fcc_document, fcc_docket, fcc_citation, action_date,
    removal_reason, contact_name, contact_email,
    email_researched
) VALUES (
    'RMD0015088',
    'Belthrough LLC',
    '1942 Broadway, Ste 314C, Boulder, CO 80302',
    'final_determination_order',
    'DA-26-237', 'EB-TCD-24-00037445', '(EB 2026)',
    '2026-03-12',
    'Originated and transited illegal prerecorded robocalls impersonating ISPs, financial services, and border protection agencies. Failed to respond to FCC Notification of Suspected Illegal Traffic (Sept 2025) and Initial Determination Order (Feb 2026). Traffic blocked industry-wide within 30 days.',
    'Brisa Cruz',
    'brisa@belthrough.com',
    TRUE
) ON CONFLICT DO NOTHING;

-- ------------------------------------------------------------
-- 2–36. 35 COMPANIES — DA-26-282 (March 24, 2026)
--    Show cause / cure or face permanent removal
--    These were provisionally reinstated after the Aug 2025
--    mass removal but still have deficient certifications.
-- ------------------------------------------------------------
INSERT INTO fcc_rmd_removed (rmd_number, business_name, action_type, fcc_document, fcc_docket, action_date, deficiency_notice_date, removal_reason) VALUES
('RMD0007602', 'makrodepot',                                               'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-17', 'RMD certification deficient — missing required robocall mitigation plan information. Provisionally reinstated after Aug 2025 mass removal; cure or face permanent removal by ~Apr 7, 2026.'),
('RMD0008963', 'ConnX Inc.',                                               'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-17', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0005673', 'Reachme.com Inc',                                          'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-19', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0007929', 'Convergence Technology Solutions Corp.',                   'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-17', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0005475', 'Skycom Healthcare',                                        'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-12-10', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0006142', 'CFX Business Solutions Inc',                               'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-09-15', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0009206', 'Daniels Business Services',                                'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-21', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0008474', 'Central Point Networks LLC',                               'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-21', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0011016', 'DTA Professionals LLC',                                    'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-09-17', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0008638', 'Voko Communications LLC',                                  'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-12-04', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0011056', 'Inn Touch Systems',                                        'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-09-22', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0009397', 'Yeltek',                                                   'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2026-01-22', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0006872', 'HIGHCOMM LLC',                                             'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2026-01-28', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0008713', 'Inatech Solutions Inc.',                                   'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-09-24', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0008142', 'phonesforward.com',                                        'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2026-01-22', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0008143', 'Dixie Net Communications',                                 'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-09-24', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0011232', 'Enhanced Business Communications LLC',                     'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-21', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0008192', 'Dynamic Network Support',                                  'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-09-24', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0005602', 'UT&T',                                                     'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2026-01-20', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0004752', 'Secure UICC',                                              'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-21', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0012459', 'Ring2Voice Inc',                                           'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2026-01-23', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0011304', 'One Too Many Insurance Agency Inc. DBA Search & Save',     'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-24', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0007940', 'Apps Communications Inc.',                                 'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-09-25', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0007131', 'Digital Division LLC',                                     'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-09-25', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0008994', 'Axxess Consult Inc',                                       'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2026-01-23', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0008919', 'Consumer Agent Portal LLC DBA TrustedChoice.com',          'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-09-25', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0008129', 'Conference America Inc.',                                  'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2026-01-23', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0008093', 'Universal E-Business Solutions LLC',                       'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2026-01-23', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0006392', 'Opex Communications Inc.',                                 'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2026-01-23', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0005094', 'Optus Networks Pty Limited',                               'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-12-19', 'RMD certification deficient — missing required robocall mitigation plan information.'),
(NULL,         'Jeremiah Connelly',                                         'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-19', 'Individual filer. RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0007323', 'CSB Technologies',                                         'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-18', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0015313', 'Easy Numbers LLC',                                         'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-18', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0008338', 'SECURE',                                                   'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2025-11-18', 'RMD certification deficient — missing required robocall mitigation plan information.'),
('RMD0002196', 'Panobit LLC',                                              'show_cause_pending', 'DA-26-282', 'EB-TCD-25-00038590', '2026-03-24', '2026-01-23', 'RMD certification deficient — missing required robocall mitigation plan information.');

-- ------------------------------------------------------------
-- 37. VIETTEL BUSINESS SOLUTIONS CO. et al. — Feb 2024 removal
--    39 FCC Rcd 1319 — 12 entities with deficient certifications
--    Note: Full list from order. Viettel is the named lead entity;
--    the remaining 11 are unnamed in public summaries — they will
--    be populated from the actual order appendix when retrieved.
-- ------------------------------------------------------------
INSERT INTO fcc_rmd_removed (
    business_name, action_type, fcc_document, fcc_citation, action_date,
    removal_reason
) VALUES (
    'Viettel Business Solutions Co.',
    'deficiency_removal',
    NULL, '39 FCC Rcd 1319', '2024-02-01',
    'Lead entity in Feb 2024 mass removal of 12 carriers with deficient RMD certifications. Failed to update certifications with required information after notice and opportunity to cure. Removed per 47 CFR § 64.6305(d)-(e).'
) ON CONFLICT DO NOTHING;

-- ------------------------------------------------------------
-- NOTE: August 2025 mass removal (1,203 carriers, 40 FCC Rcd 6009)
-- and Aug 7, 2025 removal (185 carriers) — full company lists
-- are in appendices of those orders (DA number not confirmed).
-- These will be populated once the order appendix is retrieved
-- from FCC EDOCS. The action_date and docket are known.
-- A placeholder record documents this batch:
-- ------------------------------------------------------------
INSERT INTO fcc_rmd_removed (
    business_name, action_type, fcc_docket, fcc_citation, action_date,
    removal_reason
) VALUES (
    '[1,203 carriers — Aug 2025 mass removal — appendix pending]',
    'deficiency_removal',
    'EB-TCD-25-00038590', '40 FCC Rcd 6009', '2025-08-25',
    'Largest single RMD removal in program history. 1,203 providers removed for failing to respond to the Dec 2024 Show Cause Order (39 FCC Rcd 13318) regarding deficient certifications. Full appendix to be retrieved from FCC EDOCS DA order document.'
) ON CONFLICT DO NOTHING;

COMMIT;
