CREATE TABLE IF NOT EXISTS `ChangeRequests` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `system_receipt_no` VARCHAR(255) NULL,
    `request_mgmt_no` VARCHAR(255) NULL,
    `company` VARCHAR(255) NOT NULL,
    `hq_name` VARCHAR(255) NOT NULL,
    `department_name` VARCHAR(255) NOT NULL,
    `requester_name` VARCHAR(255) NOT NULL,
    `extension` VARCHAR(255) NULL,
    `issued_date` DATE NOT NULL,
    `desired_date` DATE NULL,
    `has_attachment` BOOLEAN DEFAULT FALSE,
    `request_title` VARCHAR(255) NOT NULL,
    `background_purpose` TEXT NOT NULL,
    `implementation_details` TEXT NOT NULL,
    `quantitative_effect` TEXT NULL,
    `basis_of_calculation` TEXT NULL,
    `qualitative_effect` TEXT NULL,
    `category` ENUM('Legal', 'Business Challenge', 'Cust. Complaint', 'Cust. Request', 'Settings/Conversions', 'Improvement', 'Other') NOT NULL,
    `impact_range` ENUM('All ROHM', 'Within Headquarters', 'Within Dept/Div', 'Other') NOT NULL,
    `workload_estimation` DECIMAL(10, 2) NULL,
    `scheduled_start_date` DATE NULL,
    `system_div_comments` TEXT NULL,
    `effect_confirmation_required` BOOLEAN DEFAULT FALSE,
    `actual_effect_amount` DECIMAL(10, 2) NULL,
    `status` ENUM('Draft', 'Dept_Approval_Pending', 'System_Reception', 'Under_Consideration', 'In_Progress', 'Completed', 'Rejected') DEFAULT 'Draft'
);

CREATE TABLE IF NOT EXISTS `Attachments` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `request_id` INT NOT NULL,
    `file_path` VARCHAR(255) NOT NULL,
    `file_name` VARCHAR(255) NOT NULL,
    FOREIGN KEY (`request_id`) REFERENCES `ChangeRequests`(`id`) ON DELETE CASCADE
);
