Summary
The TranslatedEvent type includes a schemaVersion field that carries the version label of the blueprint schema that translated the event — for example, "v2" or "1.0.0". This field is computed correctly in translateEvent() and returned in the TranslatedEvent object. However, the Event model in prisma/schema.prisma has no schemaVersion column. The translateAndPersistEvent function in lib/translator/persistence.ts does not write it to the database. The value is computed and then silently discarded on every event write. Every event in the database has schemaVersion: null regardless of which blueprint version processed it.
Background
schemaVersion is the mechanism that allows operators to audit which schema version was applied to historical events. This matters when a contract is upgraded and a new blueprint version is registered with a new validFromLedger. Without schemaVersion persisted, it is impossible to query the database and find all events processed by a specific schema version — for example, to identify events that need re-translation after a blueprint bug fix.
Required work
Add a schemaVersion column to the Event model in prisma/schema.prisma as a nullable string. Create a Prisma migration. Update translateAndPersistEvent in persistence.ts to include schemaVersion: translated.schemaVersion in both the create and update blocks of the db.event.upsert call. Update GET /api/v1/events to include schemaVersion in its response shape. Update the export route in app/api/v1/events/export/route.ts to include schemaVersion as a column in CSV exports and a field in JSON/NDJSON exports. Add an index on schemaVersion to the Prisma schema to support efficient queries filtering by schema version. Write tests proving that an event translated by a versioned blueprint has its schemaVersion correctly written to the database and returned by the API.
Acceptance criteria
Every event in the database has a non-null schemaVersion when translated by a versioned blueprint. The field appears in API responses and exports. A Prisma migration is included. Tests confirm the full persistence path from translateEvent() to the database row.
Summary
The TranslatedEvent type includes a schemaVersion field that carries the version label of the blueprint schema that translated the event — for example, "v2" or "1.0.0". This field is computed correctly in translateEvent() and returned in the TranslatedEvent object. However, the Event model in prisma/schema.prisma has no schemaVersion column. The translateAndPersistEvent function in lib/translator/persistence.ts does not write it to the database. The value is computed and then silently discarded on every event write. Every event in the database has schemaVersion: null regardless of which blueprint version processed it.
Background
schemaVersion is the mechanism that allows operators to audit which schema version was applied to historical events. This matters when a contract is upgraded and a new blueprint version is registered with a new validFromLedger. Without schemaVersion persisted, it is impossible to query the database and find all events processed by a specific schema version — for example, to identify events that need re-translation after a blueprint bug fix.
Required work
Add a schemaVersion column to the Event model in prisma/schema.prisma as a nullable string. Create a Prisma migration. Update translateAndPersistEvent in persistence.ts to include schemaVersion: translated.schemaVersion in both the create and update blocks of the db.event.upsert call. Update GET /api/v1/events to include schemaVersion in its response shape. Update the export route in app/api/v1/events/export/route.ts to include schemaVersion as a column in CSV exports and a field in JSON/NDJSON exports. Add an index on schemaVersion to the Prisma schema to support efficient queries filtering by schema version. Write tests proving that an event translated by a versioned blueprint has its schemaVersion correctly written to the database and returned by the API.
Acceptance criteria
Every event in the database has a non-null schemaVersion when translated by a versioned blueprint. The field appears in API responses and exports. A Prisma migration is included. Tests confirm the full persistence path from translateEvent() to the database row.