-- CreateTable
CREATE TABLE `Message` (
    `id` VARCHAR(36) NOT NULL,
    `agentId` INTEGER NULL,
    `from` VARCHAR(20) NOT NULL,
    `to` VARCHAR(20) NOT NULL,
    `body` TEXT NOT NULL,
    `direction` ENUM('inbound', 'outbound') NOT NULL,
    `status` ENUM('sent', 'delivered', 'failed', 'received') NOT NULL DEFAULT 'sent',
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),

    INDEX `Message_agentId_idx`(`agentId`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `Message` ADD CONSTRAINT `Message_agentId_fkey` FOREIGN KEY (`agentId`) REFERENCES `User`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
