CREATE TABLE daily_platform_stats (
 id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, client_id BIGINT UNSIGNED NOT NULL,
 stat_date DATE NOT NULL, platform_key VARCHAR(100) NOT NULL,
 metric_key VARCHAR(50) NOT NULL DEFAULT 'followers', metric_value BIGINT NOT NULL DEFAULT 0,
 notes VARCHAR(255) NULL, entered_by BIGINT UNSIGNED NULL,
 created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
 updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 UNIQUE KEY uq_daily_platform_metric (client_id,stat_date,platform_key,metric_key),
 INDEX idx_daily_client_date (client_id,stat_date),
 CONSTRAINT fk_daily_client FOREIGN KEY (client_id) REFERENCES clients(id) ON DELETE CASCADE,
 CONSTRAINT fk_daily_user FOREIGN KEY (entered_by) REFERENCES users(id) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
