﻿-- Link course_enrollment_agreements back to the source template for auditability

ALTER TABLE `course_enrollment_agreements`
  ADD COLUMN `agreement_template_id` int(11) DEFAULT NULL AFTER `student_id`,
  ADD KEY `idx_agreement_template_id` (`agreement_template_id`),
  ADD CONSTRAINT `fk_enrollment_agreements_template_id` FOREIGN KEY (`agreement_template_id`) REFERENCES `agreement_templates` (`id`) ON DELETE SET NULL;
