0001_huge_sway.sql 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. CREATE TABLE `conversations` (
  2. `id` int AUTO_INCREMENT NOT NULL,
  3. `sessionId` varchar(64) NOT NULL,
  4. `visitorName` varchar(255),
  5. `visitorEmail` varchar(320),
  6. `status` enum('active','escalated','resolved','closed') NOT NULL DEFAULT 'active',
  7. `assignedAgentId` int,
  8. `metadata` json,
  9. `createdAt` timestamp NOT NULL DEFAULT (now()),
  10. `updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  11. CONSTRAINT `conversations_id` PRIMARY KEY(`id`),
  12. CONSTRAINT `conversations_sessionId_unique` UNIQUE(`sessionId`)
  13. );
  14. --> statement-breakpoint
  15. CREATE TABLE `messages` (
  16. `id` int AUTO_INCREMENT NOT NULL,
  17. `conversationId` int NOT NULL,
  18. `sender` enum('visitor','bot','agent') NOT NULL,
  19. `content` text NOT NULL,
  20. `metadata` json,
  21. `createdAt` timestamp NOT NULL DEFAULT (now()),
  22. CONSTRAINT `messages_id` PRIMARY KEY(`id`)
  23. );
  24. --> statement-breakpoint
  25. CREATE TABLE `workflow_edges` (
  26. `id` int AUTO_INCREMENT NOT NULL,
  27. `workflowId` varchar(64) NOT NULL,
  28. `sourceNodeId` varchar(64) NOT NULL,
  29. `targetNodeId` varchar(64) NOT NULL,
  30. `label` varchar(255),
  31. `condition` json,
  32. `createdAt` timestamp NOT NULL DEFAULT (now()),
  33. CONSTRAINT `workflow_edges_id` PRIMARY KEY(`id`)
  34. );
  35. --> statement-breakpoint
  36. CREATE TABLE `workflow_nodes` (
  37. `id` int AUTO_INCREMENT NOT NULL,
  38. `workflowId` varchar(64) NOT NULL,
  39. `nodeId` varchar(64) NOT NULL,
  40. `type` enum('greeting','intent','response','condition','escalation','action','end') NOT NULL,
  41. `label` varchar(255) NOT NULL,
  42. `config` json,
  43. `positionX` int NOT NULL DEFAULT 0,
  44. `positionY` int NOT NULL DEFAULT 0,
  45. `createdAt` timestamp NOT NULL DEFAULT (now()),
  46. `updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
  47. CONSTRAINT `workflow_nodes_id` PRIMARY KEY(`id`)
  48. );