-- CreateTable
CREATE TABLE `AdminConversation` (
    `id` VARCHAR(191) NOT NULL,
    `adminUserId` VARCHAR(191) NOT NULL,
    `title` VARCHAR(200) NOT NULL DEFAULT '新对话',
    `hermesSessionId` VARCHAR(64) NOT NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,
    `deletedAt` DATETIME(3) NULL,
    UNIQUE INDEX `AdminConversation_hermesSessionId_key`(`hermesSessionId`),
    INDEX `AdminConversation_adminUserId_idx`(`adminUserId`),
    INDEX `AdminConversation_hermesSessionId_idx`(`hermesSessionId`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `AdminMessage` (
    `id` VARCHAR(191) NOT NULL,
    `conversationId` VARCHAR(191) NOT NULL,
    `role` VARCHAR(16) NOT NULL,
    `content` LONGTEXT NOT NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    INDEX `AdminMessage_conversationId_idx`(`conversationId`),
    INDEX `AdminMessage_createdAt_idx`(`createdAt`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `AdminConversation` ADD CONSTRAINT `AdminConversation_adminUserId_fkey` FOREIGN KEY (`adminUserId`) REFERENCES `AdminUser`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE `AdminMessage` ADD CONSTRAINT `AdminMessage_conversationId_fkey` FOREIGN KEY (`conversationId`) REFERENCES `AdminConversation`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
