-- Create LL Results Table
CREATE TABLE IF NOT EXISTS `ll_results` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `application_no` varchar(50) NOT NULL UNIQUE,
    `name` varchar(100) DEFAULT NULL,
    `dob` date DEFAULT NULL,
    `score` decimal(3,1) DEFAULT '0.0',
    `result` enum('Pass','Fail','Pending') DEFAULT 'Pending',
    `license_number` varchar(50) DEFAULT NULL,
    `screenshot_url` text DEFAULT NULL,
    `status` enum('Processing','Completed','Failed') DEFAULT 'Processing',
    `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
    `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    KEY `application_no` (`application_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Add columns to printRecords if not exists
ALTER TABLE printRecords 
ADD COLUMN IF NOT EXISTS license_number varchar(50) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS ll_score decimal(3,1) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS ll_result enum('Pass','Fail','Pending') DEFAULT 'Pending',
ADD COLUMN IF NOT EXISTS screenshot_url text DEFAULT NULL;