Database question about new table columns

Added by Smorgas Borg about 4 years ago

I need to track changes in my Redmine database so I created an extra timestamp field and added triggers to a new table where my history is stored. I created a single test on the ATTACHMENTS table and now I'm getting messages like this in the history section of an issue:
  1. translation missing: en.field_DATETIME_LAST_CHG changed from 2013-12-12 14:05:04 to 2013-12-13 08:04:26

So, I'm guessing that Redmine is dynamically reading every column in that table and trying to display the information. Is there a way to easily fix this or is this behavior so deeply embedded in Redmine that it can't be undone? Is this possibly just a problem with how history records are being created or is it likely to pop up in other places as I add an extra field to the other tables?

Environment:
Redmine version 2.3.2.stable
Ruby version 1.9.3-p448 (2013-06-27) [x86_64-linux]
Rails version 3.2.13
Environment production
Database adapter Mysql2
Redmine plugins:
redmine_backlogs v1.0.6
redmine_banner 0.0.9
redmine_charts2 0.2.1
redmine_custom_field_hints 0.0.3
redmine_graphs 0.1.0
redmine_importer 1.0
redmine_people 0.1.6
redmine_release_notes 1.3.1

EDIT: From what I've seen so far, it looks like this is just affecting the history records that are being inserted into the journal_details table.

Replies (1)

RE: Database question about new table columns - Added by Smorgas Borg almost 4 years ago

It drove me crazy trying to figure out how to stop these records from being logged and retrieved until I remembered that Redmine has no database constraints. I just set a trigger to change the journal_id to one that doesn't exist. Problem solved.

CREATE TRIGGER journal_details_HIDE_DATETIME_LAST_CHG BEFORE INSERT ON journal_details
FOR EACH ROW
BEGIN
IF (NEW.PROP_KEY = 'DATETIME_LAST_CHG') THEN
SET NEW.journal_id=-1;
END IF;
END

(1-1/1)