|
|
|
|
@ -12,6 +12,7 @@ const { UptimeCalculator } = require("./uptime-calculator");
|
|
|
|
|
const dayjs = require("dayjs");
|
|
|
|
|
const { SimpleMigrationServer } = require("./utils/simple-migration-server");
|
|
|
|
|
const KumaColumnCompiler = require("./utils/knex/lib/dialects/mysql2/schema/mysql2-columncompiler");
|
|
|
|
|
const SqlString = require("sqlstring");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Database & App Data Folder
|
|
|
|
|
@ -256,10 +257,6 @@ class Database {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
} else if (dbConfig.type === "mariadb") {
|
|
|
|
|
if (!/^\w+$/.test(dbConfig.dbName)) {
|
|
|
|
|
throw Error("Invalid database name. A database name can only consist of letters, numbers and underscores");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const connection = await mysql.createConnection({
|
|
|
|
|
host: dbConfig.hostname,
|
|
|
|
|
port: dbConfig.port,
|
|
|
|
|
@ -267,7 +264,11 @@ class Database {
|
|
|
|
|
password: dbConfig.password,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await connection.execute("CREATE DATABASE IF NOT EXISTS " + dbConfig.dbName + " CHARACTER SET utf8mb4");
|
|
|
|
|
// Set to true, so for example "uptime.kuma", becomes `uptime.kuma`, not `uptime`.`kuma`
|
|
|
|
|
// Doc: https://github.com/mysqljs/sqlstring?tab=readme-ov-file#escaping-query-identifiers
|
|
|
|
|
const escapedDBName = SqlString.escapeId(dbConfig.dbName, true);
|
|
|
|
|
|
|
|
|
|
await connection.execute("CREATE DATABASE IF NOT EXISTS " + escapedDBName + " CHARACTER SET utf8mb4");
|
|
|
|
|
connection.end();
|
|
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
|