My very simple idea is to compare the id with all the records in history and concatenate the text to a matching record found. Null values should be ignored. If no matching record is found, a new record should be created. If multiple matching records are found, a warning should be emitted into the log and the most recent record should be used to append text to.