Rearchitect iiirecord.record_metadata to provide improved audit trail accountability
It is sometimes helpful to see who created, updated or deleted a record. Catmaint provides a lot of detail but doesn't cover many record types. I propose the following solution, which doesn't have particularly burdensome storage requirements:
- Build a many-to-many table with an id primary key column, a timestamp, a code indicating the C-R-U-Uprevious-D record operation and foreign keys linking to record_metadata.id and to iii_user.id.
- Backfill this new table using the available timestamps in record_metadata, catmaint and any other table like catmaint which might provide record edit history.
- Rename record_metadata and drop its four *_gmt timestamp columns. Yes, this creates a chicken/egg catch-22 for the foreign keys created in step 1. Clever Innovative staff find a solution.
- Create a view named record_metadata which provides backward compatibility for read operations.
- Creates/Updates/Deletes to the former record_metadata now require recoding, which may not be too awful if these operations are currently managed by stored procs and possibly triggers.

-
Bob Gaydos commented
I just realized that deletes of iii_user would result in null references from the many-to-many table described in step 1 above. Add a deletion_date_gmt column to iii_user (like record_metadata currently has) so that no iii_user rows are ever actually deleted.