36716-vm/db/migrations/028_create_client_surveys_table.sql
2025-12-07 05:00:42 +00:00

15 lines
659 B
SQL

CREATE TABLE `client_surveys` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`client_id` int(11) NOT NULL,
`survey_id` int(11) NOT NULL,
`status` enum('pending','completed') NOT NULL DEFAULT 'pending',
`completed_at` timestamp NULL DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `client_id` (`client_id`),
KEY `survey_id` (`survey_id`),
CONSTRAINT `client_surveys_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE,
CONSTRAINT `client_surveys_ibfk_2` FOREIGN KEY (`survey_id`) REFERENCES `surveys` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;