CREATE TABLE `tickets` (
	`id` int AUTO_INCREMENT NOT NULL,
	`ticketNumber` varchar(32) NOT NULL,
	`clientId` int,
	`contactName` varchar(255) NOT NULL,
	`contactEmail` varchar(320),
	`contactPhone` varchar(64),
	`channel` enum('whatsapp','email','chat','call','other') NOT NULL DEFAULT 'other',
	`subject` varchar(512) NOT NULL,
	`description` text,
	`priority` enum('low','normal','high','urgent') NOT NULL DEFAULT 'normal',
	`status` enum('new','in_progress','waiting_client','resolved','closed') NOT NULL DEFAULT 'new',
	`assignedAgentId` int,
	`language` varchar(8) DEFAULT 'fr',
	`resolvedAt` timestamp,
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `tickets_id` PRIMARY KEY(`id`)
);
