-- Per-site email notification toggles + recipient for WHP-managed WordPress
-- sites. When a backup or update finishes (or fails), WHP fires an email to
-- notification_email if the matching notify_* flag is on. Each event is opt-in
-- independently — a customer might want only failure alerts, or only backup
-- completion confirmations, etc.
--
-- The recipient is intentionally separate from wordpress_sites.admin_email so
-- ops/devops addresses can receive notifications while admin_email stays
-- customer-facing.

USE whp;

ALTER TABLE wordpress_sites
    ADD COLUMN IF NOT EXISTS notification_email VARCHAR(255) DEFAULT NULL
        COMMENT 'Recipient for backup/update notifications. NULL = no email even if a notify_* flag is on.'
        AFTER admin_email,
    ADD COLUMN IF NOT EXISTS notify_backup_complete TINYINT(1) NOT NULL DEFAULT 0
        AFTER notification_email,
    ADD COLUMN IF NOT EXISTS notify_backup_failed TINYINT(1) NOT NULL DEFAULT 0
        AFTER notify_backup_complete,
    ADD COLUMN IF NOT EXISTS notify_update_complete TINYINT(1) NOT NULL DEFAULT 0
        AFTER notify_backup_failed,
    ADD COLUMN IF NOT EXISTS notify_update_failed TINYINT(1) NOT NULL DEFAULT 0
        AFTER notify_update_complete;
