| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- CREATE TABLE `conversations` (
- `id` int AUTO_INCREMENT NOT NULL,
- `sessionId` varchar(64) NOT NULL,
- `visitorName` varchar(255),
- `visitorEmail` varchar(320),
- `status` enum('active','escalated','resolved','closed') NOT NULL DEFAULT 'active',
- `assignedAgentId` int,
- `metadata` json,
- `createdAt` timestamp NOT NULL DEFAULT (now()),
- `updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
- CONSTRAINT `conversations_id` PRIMARY KEY(`id`),
- CONSTRAINT `conversations_sessionId_unique` UNIQUE(`sessionId`)
- );
- --> statement-breakpoint
- CREATE TABLE `messages` (
- `id` int AUTO_INCREMENT NOT NULL,
- `conversationId` int NOT NULL,
- `sender` enum('visitor','bot','agent') NOT NULL,
- `content` text NOT NULL,
- `metadata` json,
- `createdAt` timestamp NOT NULL DEFAULT (now()),
- CONSTRAINT `messages_id` PRIMARY KEY(`id`)
- );
- --> statement-breakpoint
- CREATE TABLE `workflow_edges` (
- `id` int AUTO_INCREMENT NOT NULL,
- `workflowId` varchar(64) NOT NULL,
- `sourceNodeId` varchar(64) NOT NULL,
- `targetNodeId` varchar(64) NOT NULL,
- `label` varchar(255),
- `condition` json,
- `createdAt` timestamp NOT NULL DEFAULT (now()),
- CONSTRAINT `workflow_edges_id` PRIMARY KEY(`id`)
- );
- --> statement-breakpoint
- CREATE TABLE `workflow_nodes` (
- `id` int AUTO_INCREMENT NOT NULL,
- `workflowId` varchar(64) NOT NULL,
- `nodeId` varchar(64) NOT NULL,
- `type` enum('greeting','intent','response','condition','escalation','action','end') NOT NULL,
- `label` varchar(255) NOT NULL,
- `config` json,
- `positionX` int NOT NULL DEFAULT 0,
- `positionY` int NOT NULL DEFAULT 0,
- `createdAt` timestamp NOT NULL DEFAULT (now()),
- `updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
- CONSTRAINT `workflow_nodes_id` PRIMARY KEY(`id`)
- );
|