-- AlterTable: add ANONYMIZE to ModerationActionType
ALTER TABLE `user_moderation_actions`
    MODIFY `action` ENUM('SUSPEND', 'RESTORE', 'DELETE', 'ROLE_CHANGE', 'VERIFY', 'UNVERIFY', 'ACTIVATE', 'DEACTIVATE', 'ANONYMIZE') NOT NULL;

-- CreateTable
CREATE TABLE `admin_action_challenges` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `admin_id` INTEGER NOT NULL,
    `target_user_id` INTEGER NOT NULL,
    `mode` ENUM('ANONYMIZE', 'DELETE') NOT NULL,
    `code_hash` VARCHAR(255) NOT NULL,
    `attempts` INTEGER NOT NULL DEFAULT 0,
    `expires_at` DATETIME(3) NOT NULL,
    `consumed_at` DATETIME(3) NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),

    INDEX `admin_action_challenges_admin_id_idx`(`admin_id`),
    INDEX `admin_action_challenges_expires_at_idx`(`expires_at`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `admin_action_challenges` ADD CONSTRAINT `admin_action_challenges_admin_id_fkey` FOREIGN KEY (`admin_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
