GH-836 - Add support for MariaDB database.

This commit is contained in:
FezLight
2024-09-24 00:47:06 +02:00
committed by Oliver Drotbohm
parent 0c2f79a56d
commit e0b79e5fb1
8 changed files with 75 additions and 0 deletions

View File

@@ -104,6 +104,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mariadb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mssqlserver</artifactId>
@@ -140,6 +146,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -50,6 +50,24 @@ enum DatabaseType {
}
},
MARIADB("mariadb", "MariaDB") {
@Override
Object uuidToDatabase(UUID id) {
return id.toString();
}
@Override
UUID databaseToUUID(Object id) {
return UUID.fromString(id.toString());
}
@Override
boolean isSchemaSupported() {
return false;
}
},
POSTGRES("postgresql", "PostgreSQL"),
MSSQL("sqlserver", "Microsoft SQL Server") {

View File

@@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS EVENT_PUBLICATION
(
ID VARCHAR(36) NOT NULL,
LISTENER_ID VARCHAR(512) NOT NULL,
EVENT_TYPE VARCHAR(512) NOT NULL,
SERIALIZED_EVENT VARCHAR(4000) NOT NULL,
PUBLICATION_DATE TIMESTAMP(6) NOT NULL,
COMPLETION_DATE TIMESTAMP(6) DEFAULT NULL NULL,
PRIMARY KEY (ID),
INDEX EVENT_PUBLICATION_BY_COMPLETION_DATE_IDX (COMPLETION_DATE)
);

View File

@@ -123,6 +123,10 @@ class DatabaseSchemaInitializerIntegrationTests {
@ActiveProfiles("mysql")
class MySQL extends WithInitEnabled {}
@Nested
@ActiveProfiles("mariadb")
class MariaDB extends WithInitEnabled {}
@Nested
@ActiveProfiles("mssql")
class MSSQL extends WithInitEnabled {}

View File

@@ -47,6 +47,13 @@ class DatabaseSchemaInitializerUnitTests {
assertThatIllegalStateException().isThrownBy(() -> createInitializer(withSchema(schema), DatabaseType.MYSQL));
}
// GH-836
@ParameterizedTest
@ValueSource(strings = { "", "test" })
void rejectsExplicitSchemaNameForMariDB(String schema) {
assertThatIllegalStateException().isThrownBy(() -> createInitializer(withSchema(schema), DatabaseType.MARIADB));
}
// GH-804
@ParameterizedTest
@ValueSource(strings = { "", "test" })

View File

@@ -469,6 +469,14 @@ class JdbcEventPublicationRepositoryIntegrationTests {
@WithMySql
class MysqlWithDeleteCompletion extends WithDeleteCompletion {}
// MariaDB
@WithMariaDB
class MariaDBWithNoDefinedSchemaName extends WithNoDefinedSchemaName {}
@WithMariaDB
class MariaDBWithDeleteCompletion extends WithDeleteCompletion {}
@Value
private static final class TestEvent {
String eventId;
@@ -493,6 +501,11 @@ class JdbcEventPublicationRepositoryIntegrationTests {
@Retention(RetentionPolicy.RUNTIME)
@interface WithMySql {}
@Nested
@ActiveProfiles("mariadb")
@Retention(RetentionPolicy.RUNTIME)
@interface WithMariaDB {}
@Nested
@ActiveProfiles("postgres")
@Retention(RetentionPolicy.RUNTIME)

View File

@@ -0,0 +1,2 @@
spring.datasource.url=jdbc:tc:mariadb:11.5.2:///events
spring.datasource.driverClassName=org.testcontainers.jdbc.ContainerDatabaseDriver

View File

@@ -203,6 +203,14 @@ include::{jdbc-schema-base}/schema-hsqldb.sql[]
include::{jdbc-schema-base}/schema-mysql.sql[]
----
[[schemas.mariadb]]
=== MariaDB
[source, sql]
----
include::{jdbc-schema-base}/schema-mariadb.sql[]
----
[[schemas.postgresql]]
=== PostgreSQL