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
| Field | Type | Description |
|---|---|---|
id | number | Primary key |
batchId | string | UUID shared by all changes from a single save action |
entityType | string | episode | scene | scene_block |
entityId | number | ID of the changed entity |
changedField | string | Name of the field that changed |
oldValue | string | JSON-serialized previous value |
newValue | string | JSON-serialized new value |
changedById | number | User who made the change |
changedAt | Date | Timestamp |
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).