-- School-configurable result engine.
-- Safe to run more than once.

CREATE TABLE IF NOT EXISTS `result_configurations` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `school_key` VARCHAR(120) NOT NULL,
  `profile_key` VARCHAR(40) NOT NULL,
  `configuration_json` LONGTEXT NOT NULL,
  `updated_by` BIGINT UNSIGNED DEFAULT NULL,
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_school_result_profile` (`school_key`, `profile_key`),
  KEY `idx_result_config_school` (`school_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
