feat: persist schemaVersion through the event translation pipeline - #390
Merged
Merged
Conversation
Adds schemaVersion to the Event model so operators can audit which blueprint version translated each event, instead of it being computed and silently discarded on every write.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
schemaVersioncolumn (+ index) to theEventmodel so the blueprint version label computed bytranslateEvent()is no longer discarded before it reaches the database.schemaVersionin both thecreateandupdatebranches oftranslateAndPersistEvent's upsert.schemaVersioninGET /api/v1/eventsresponses and in the CSV/JSON/NDJSON event exports.Why
Without a persisted
schemaVersion, there's no way to query historical events by the schema version that translated them — e.g. to find events needing re-translation after a blueprint bug fix or contract upgrade.Test plan
npx prisma validate/prisma generatesucceed with the updated schemapersistence.schemaVersion.test.tsconfirmschemaVersionreachesdb.event.upsertfor versioned and unversioned blueprintsevents/route.test.tsto assertschemaVersionis returned by the list APIevents/export/route.test.tsto assertschema_versionappears in CSV, JSON, and NDJSON exportssanitization.test.ts/stats/route.test.tsconfirmed present onmaintoo)Closes #377