You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The JDBC Chat Memory repository currently uses a timestamp column to maintain message ordering. However, this column is semantically misleading—it's not actually storing temporal data but rather functioning as a sequence ID to preserve message order. As @markpollack#3154 (comment), the field should have been renamed from its original implementation, and dropping the timestamp column entirely should be considered for future versions.
This has caused some confusion and technical issues:
Misleading semantics: The column name suggests temporal data, but it's actually an ordering sequence
We've implemented a non-breaking fix in #4739 that uses second-level granularity in the Java code. This solves the immediate ordering issue across all databases without requiring schema changes.
Proposed Change for 2.0
Since 2.0 is a major release where breaking changes are acceptable, we should redesign the schema to make the intent explicit:
Current schema: timestamp TIMESTAMP NOT NULL
Proposed schema: sequence_id BIGINT NOT NULL
Benefits
Clearer intent: Column name matches its actual purpose
Consistent behavior: Works identically across all databases
Simpler implementation: Direct setLong() instead of timestamp conversions
Future-proof: No range limitations or precision concerns
Update JdbcChatMemoryRepository to use setLong() instead of setTimestamp()
Update dialect classes with new column name
Create migration scripts for supported databases
Document the breaking change in migration guide
Migration Impact
This is a breaking schema change. Users will need to either run migration scripts or recreate the table. Since chat memory typically stores recent conversation context rather than permanent historical data, recreation is often acceptable.
Background
The JDBC Chat Memory repository currently uses a timestamp column to maintain message ordering. However, this column is semantically misleading—it's not actually storing temporal data but rather functioning as a sequence ID to preserve message order. As @markpollack #3154 (comment), the field should have been renamed from its original implementation, and dropping the timestamp column entirely should be considered for future versions.
This has caused some confusion and technical issues:
Current State (1.0.x / 1.1.x)
We've implemented a non-breaking fix in #4739 that uses second-level granularity in the Java code. This solves the immediate ordering issue across all databases without requiring schema changes.
Proposed Change for 2.0
Since 2.0 is a major release where breaking changes are acceptable, we should redesign the schema to make the intent explicit:
Current schema:
timestamp TIMESTAMP NOT NULLProposed schema:
sequence_id BIGINT NOT NULLBenefits
setLong()instead of timestamp conversionsImplementation Tasks
JdbcChatMemoryRepositoryto usesetLong()instead ofsetTimestamp()Migration Impact
This is a breaking schema change. Users will need to either run migration scripts or recreate the table. Since chat memory typically stores recent conversation context rather than permanent historical data, recreation is often acceptable.
Related Discussions