fix: move afterCreate to initial mariadb pool config (#7718)

This commit is contained in:
otbutz
2026-08-22 16:04:20 +02:00
committed by GitHub
parent 3bb164439d
commit 6398a9581d
+4 -9
View File
@@ -285,6 +285,10 @@ class Database {
min: 0, min: 0,
max: parsedMaxPoolConnections, max: parsedMaxPoolConnections,
idleTimeoutMillis: 30000, idleTimeoutMillis: 30000,
afterCreate(conn, done) {
// Set to utf8mb4 for MariaDB
conn.query("SET CHARACTER SET utf8mb4;", (err) => done(err, conn));
},
}; };
log.info("db", `Database Type: ${dbConfig.type}`); log.info("db", `Database Type: ${dbConfig.type}`);
@@ -409,15 +413,6 @@ class Database {
throw new Error("Unknown Database type: " + dbConfig.type); throw new Error("Unknown Database type: " + dbConfig.type);
} }
// Set to utf8mb4 for MariaDB
if (dbConfig.type.endsWith("mariadb")) {
config.pool = {
afterCreate(conn, done) {
conn.query("SET CHARACTER SET utf8mb4;", (err) => done(err, conn));
},
};
}
const knexInstance = knex(config); const knexInstance = knex(config);
R.setup(knexInstance); R.setup(knexInstance);