@oscman
That's strange,... foreign key was not added for fluent installation, easiest solution for you is to add foreign key on t_messages table on key t_messages.fk_i_thread_id -> t_threads.i_thread_id
Also update in model function removeThreadsByDate as following:
public function removeThreadsByDate( $datetime ) {
$this->dao->query('DELETE FROM '. $this->getTable_messages() . ' WHERE fk_i_thread_id in (SELECT i_thread_id FROM '. $this->getTable_threads() . ' WHERE d_datetime <= "' . $datetime . '")' . $thread_id );
$this->dao->query('DELETE FROM '. $this->getTable_threads() . ' WHERE d_datetime <= "' . $datetime . '"' );
}