From cd366b48a2a8f591045158777ed685994cb41eb5 Mon Sep 17 00:00:00 2001 From: Seungwon Lee Date: Thu, 5 Jun 2025 04:58:44 +0900 Subject: [PATCH] Fix: MySQL/MariaDB TIMESTAMP precision for message ordering (#3442) Fixes #3442 Signed-off-by: Seungwon Lee --- .../ai/chat/memory/repository/jdbc/schema-mariadb.sql | 2 +- .../ai/chat/memory/repository/jdbc/schema-mysql.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/memory/repository/spring-ai-model-chat-memory-repository-jdbc/src/main/resources/org/springframework/ai/chat/memory/repository/jdbc/schema-mariadb.sql b/memory/repository/spring-ai-model-chat-memory-repository-jdbc/src/main/resources/org/springframework/ai/chat/memory/repository/jdbc/schema-mariadb.sql index 6a0ef8755ef..68adea5bf1d 100644 --- a/memory/repository/spring-ai-model-chat-memory-repository-jdbc/src/main/resources/org/springframework/ai/chat/memory/repository/jdbc/schema-mariadb.sql +++ b/memory/repository/spring-ai-model-chat-memory-repository-jdbc/src/main/resources/org/springframework/ai/chat/memory/repository/jdbc/schema-mariadb.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS SPRING_AI_CHAT_MEMORY ( conversation_id VARCHAR(36) NOT NULL, content TEXT NOT NULL, type VARCHAR(10) NOT NULL, - `timestamp` TIMESTAMP NOT NULL, + `timestamp` TIMESTAMP(3) NOT NULL, CONSTRAINT TYPE_CHECK CHECK (type IN ('USER', 'ASSISTANT', 'SYSTEM', 'TOOL')) ); diff --git a/memory/repository/spring-ai-model-chat-memory-repository-jdbc/src/main/resources/org/springframework/ai/chat/memory/repository/jdbc/schema-mysql.sql b/memory/repository/spring-ai-model-chat-memory-repository-jdbc/src/main/resources/org/springframework/ai/chat/memory/repository/jdbc/schema-mysql.sql index f8edb0c5827..ce7a7a4a031 100644 --- a/memory/repository/spring-ai-model-chat-memory-repository-jdbc/src/main/resources/org/springframework/ai/chat/memory/repository/jdbc/schema-mysql.sql +++ b/memory/repository/spring-ai-model-chat-memory-repository-jdbc/src/main/resources/org/springframework/ai/chat/memory/repository/jdbc/schema-mysql.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS SPRING_AI_CHAT_MEMORY ( `conversation_id` VARCHAR(36) NOT NULL, `content` TEXT NOT NULL, `type` ENUM('USER', 'ASSISTANT', 'SYSTEM', 'TOOL') NOT NULL, - `timestamp` TIMESTAMP NOT NULL, + `timestamp` TIMESTAMP(3) NOT NULL, INDEX `SPRING_AI_CHAT_MEMORY_CONVERSATION_ID_TIMESTAMP_IDX` (`conversation_id`, `timestamp`) );