-- Apply AFTER 2026_09_29_followup_audio.sql, BEFORE deploying delete-aware application code. -- Re-runnable. Preserve original content SHA, upload binding, provider and all encrypted snapshots. -- Rollback: leave these additive columns/index in place and disable deletion first. -- Old application code must NOT be restored after tombstones exist: it exposes hidden tasks. -- Restoring the old unique key is not generally possible after same-content reuploads. SET @fa_db = DATABASE(); SET @fa_sql = IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@fa_db AND TABLE_NAME='zyt_followup_audio_task' AND COLUMN_NAME='active_slot')=0, 'ALTER TABLE zyt_followup_audio_task ADD COLUMN active_slot BIGINT UNSIGNED NOT NULL DEFAULT 0, ADD COLUMN deleted_at BIGINT UNSIGNED NOT NULL DEFAULT 0, ADD COLUMN deleted_by BIGINT UNSIGNED NOT NULL DEFAULT 0, ADD COLUMN deletion_json TEXT NULL', 'SELECT 1'); PREPARE fa_stmt FROM @fa_sql; EXECUTE fa_stmt; DEALLOCATE PREPARE fa_stmt; SET @fa_sql = IF((SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA=@fa_db AND TABLE_NAME='zyt_followup_audio_task' AND INDEX_NAME='uk_content_profile' AND COLUMN_NAME='active_slot')=0, 'ALTER TABLE zyt_followup_audio_task DROP INDEX uk_content_profile, ADD UNIQUE KEY uk_content_profile (diagnosis_id,sha256,model_key,active_slot)', 'SELECT 1'); PREPARE fa_stmt FROM @fa_sql; EXECUTE fa_stmt; DEALLOCATE PREPARE fa_stmt;