CREATE TABLE IF NOT EXISTS workshop_entries (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    vehicle_id BIGINT UNSIGNED NOT NULL,
    workshop_date DATE NOT NULL,
    workshop_name VARCHAR(255) NULL,
    service_type ENUM('Maintenance','Repair','Inspection','Other') NULL,
    cost DECIMAL(10,2) NULL DEFAULT 0,
    status ENUM('Pending','In Progress','Completed') NOT NULL DEFAULT 'Pending',
    notes TEXT NULL,
    created_by_user_id BIGINT UNSIGNED NULL,
    created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    KEY idx_workshop_entries_vehicle (vehicle_id),
    KEY idx_workshop_entries_date (workshop_date),
    KEY idx_workshop_entries_status (status),
    CONSTRAINT fk_workshop_entries_vehicle
        FOREIGN KEY (vehicle_id) REFERENCES vehicles(id)
        ON UPDATE CASCADE
        ON DELETE CASCADE,
    CONSTRAINT fk_workshop_entries_created_by
        FOREIGN KEY (created_by_user_id) REFERENCES users(id)
        ON UPDATE CASCADE
        ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;