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

14 lines
623 B
SQL

CREATE TABLE `survey_responses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`client_survey_id` int(11) NOT NULL,
`question_id` int(11) NOT NULL,
`response` text,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `client_survey_id` (`client_survey_id`),
KEY `question_id` (`question_id`),
CONSTRAINT `survey_responses_ibfk_1` FOREIGN KEY (`client_survey_id`) REFERENCES `client_surveys` (`id`) ON DELETE CASCADE,
CONSTRAINT `survey_responses_ibfk_2` FOREIGN KEY (`question_id`) REFERENCES `survey_questions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;