Add MySQL schema for SPRING_AI_CHAT_MEMORY

Signed-off-by: Henning Pöttker <25299532+hpoettker@users.noreply.github.com>
This commit is contained in:
Henning Pöttker
2025-05-25 00:41:42 +02:00
committed by Ilayaperumal Gopinathan
parent a0d187d14d
commit 9f58520a12
5 changed files with 62 additions and 2 deletions

View File

@@ -73,6 +73,14 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>${mysql.version}</version>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
@@ -104,6 +112,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mssqlserver</artifactId>

View File

@@ -0,0 +1,8 @@
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,
INDEX `SPRING_AI_CHAT_MEMORY_CONVERSATION_ID_TIMESTAMP_IDX` (`conversation_id`, `timestamp`)
);

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2023-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ai.chat.memory.repository.jdbc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.jdbc.Sql;
/**
* Integration tests for {@link JdbcChatMemoryRepository} with MariaDB.
*
* @author Jonathan Leijendekker
* @author Thomas Vitale
* @author Mark Pollack
* @author Yanming Zhou
*/
@SpringBootTest
@TestPropertySource(properties = { "spring.datasource.url=jdbc:tc:mariadb:10.3.39:///" })
@Sql(scripts = "classpath:org/springframework/ai/chat/memory/repository/jdbc/schema-mariadb.sql")
class JdbcChatMemoryRepositoryMariaDbIT extends AbstractJdbcChatMemoryRepositoryIT {
}

View File

@@ -27,10 +27,11 @@ import org.springframework.test.context.jdbc.Sql;
* @author Thomas Vitale
* @author Mark Pollack
* @author Yanming Zhou
* @author Henning Pöttker
*/
@SpringBootTest
@TestPropertySource(properties = { "spring.datasource.url=jdbc:tc:mariadb:10.3.39:///" })
@Sql(scripts = "classpath:org/springframework/ai/chat/memory/repository/jdbc/schema-mariadb.sql")
@TestPropertySource(properties = { "spring.datasource.url=jdbc:tc:mysql:8.0.42:///" })
@Sql(scripts = "classpath:org/springframework/ai/chat/memory/repository/jdbc/schema-mysql.sql")
class JdbcChatMemoryRepositoryMysqlIT extends AbstractJdbcChatMemoryRepositoryIT {
}

View File

@@ -302,6 +302,7 @@
<opensearch-client.version>2.23.0</opensearch-client.version>
<postgresql.version>42.7.5</postgresql.version>
<mariadb.version>3.5.3</mariadb.version>
<mysql.version>9.2.0</mysql.version>
<commonmark.version>0.22.0</commonmark.version>
<couchbase.version>3.8.0</couchbase.version>