Skip to content

Audit Schema

Tom Anderson edited this page Mar 17, 2016 · 4 revisions

Entity Relationship Diagram

Entity Relationship Diagram created with Skipper

Fixtures

These four entities are populated using the php index.php zf-doctrine-audit:data-fixture:import tool. Once populated their data does not change unless a change happens to the target schema.

RevisionType

This fixture is one of insert, update, delete, epoch. This is the type of action a RevisionEntity audits when created.

AuditEntity

This term is used for the entities created for each target entity too. This section describes the fixture pictured above. AuditEntity maps a dynamically generated audit entity and the table used. AuditEntity has a 1:1 relationship with TargetEntity.

TargetEntity

The TargetEntity maps an entity from the target object manager and it's table name. TargetEntity has a 1:1 mapping with AuditEntity and one to many with Identifier.

Identifier

Stores primary key identifier field and column information for each TargetEntity.

Audit Metadata

These three entities store the information about every audit record.

Revision

Stores the user, comment, and timestamp for a flush() event in the target object manager. Many entities may be persisted, updated, or deleted in a single flush and this groups those audit records together.

RevisionEntity

Links a Revision to a RevisionType to a TargetEntity and stores the title (if any) for the TargetEntity at the time it was created. This title is fetched from the target entity if it has a __toString() method.

RevisionEntityIdentifierValue

Stores the Identifier values for a RevisionEntity by linking an Identifier to a RevisionEntity.

Audit Entities

For every target entity configured a [new entity and table](Audit Internals) is created for the audit object manager. These audit entities mirror the column name and data type for each column in the target database and do not have the same referential integrity or indexes. You may directly interact with these though the audit object manager. To find a mapping use the AuditEntity relationship with TargetEntity.

The primary key for each is revisionEntity_id compounded with the target table primary key(s).

Each audit entity also has a field, revisionEntity_id, which maps to RevisionEntity.

Clone this wiki locally