As I first reported an issue/feature request about general entity history, I realized that I actually would need it right now. So I proceeded to make a proof of concept in order to update my issue. But instead of updating the issue I figured that my post better belongs here in a forum where maybe more people could take part of it and I could get some more feedback.
Please see the background of this topic before continuing: #1029708: History table for any entity
First of all I took the system history table as a starting point and split the 'timestamp' column into 'first_read' and 'last_read' in order to determine if the entity has been seen since last update.
<?php
$schema['oddbit_entity_history'] = array(
'description' => 'A record of which {users} have read which entities.',
'fields' => array(
'entity_type' => array(
'description' => 'The viewed entity type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => ''
),
'eid' => array(
'description' => 'The id of the entity.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'uid' => array(
'description' => 'The {users}.uid that read the entity id.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'first_read' => array(