Skip to main content

Change History

The change history system records every field-level edit made to episodes, scenes, and scene blocks. It enables granular undo — reverting a single field change — as well as batch undo that rolls back an entire save action.

Data model​

FieldTypeDescription
idnumberPrimary key
batchIdstringUUID shared by all changes from a single save action
entityTypestringepisode | scene | scene_block
entityIdnumberID of the changed entity
changedFieldstringName of the field that changed
oldValuestringJSON-serialized previous value
newValuestringJSON-serialized new value
changedByIdnumberUser who made the change
changedAtDateTimestamp

How batching works​

When a user saves a form that updates multiple fields at once, the service generates a single batchId UUID and stamps it on every resulting change record. Reverting by batchId restores all those fields atomically.

Revert mechanism​

POST /change-history/:changeId/revert reads the oldValue, parses it, and calls the appropriate entity update service method. The revert itself is recorded as a new change entry (so it can be reverted too).

Frontend​

The change history panel is opened from the History button in the block/scene editor. It lists changes chronologically and provides Revert buttons per row and per batch.

Storage considerations​

Change history grows indefinitely. If history tables become large, consider periodic archiving of old records (e.g. changes older than 90 days on completed episodes).