-- Create question_sets table and seed a Legacy Set
CREATE TABLE IF NOT EXISTS `question_sets` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(120) NOT NULL,
  `status` enum('draft','active','archived') NOT NULL DEFAULT 'active',
  `notes` text DEFAULT NULL,
  `created_by` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Insert Legacy Set if missing
INSERT INTO `question_sets` (`name`,`status`)
SELECT 'Legacy Set (v1)','active'
WHERE NOT EXISTS (SELECT 1 FROM question_sets);

