This commit is contained in:
2025-12-03 11:45:32 +01:00
parent 4a6da06580
commit 9ab5543c5c
14 changed files with 70 additions and 10 deletions
+1 -1
View File
@@ -95,7 +95,7 @@ function createDbFromSchema(_a) {
});
if (!((_b = dbCheck === null || dbCheck === void 0 ? void 0 : dbCheck[0]) === null || _b === void 0 ? void 0 : _b.dbFullName)) {
const newDatabase = yield (0, dbHandler_1.default)({
query: `CREATE DATABASE IF NOT EXISTS \`${dbFullName}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin`,
query: `CREATE DATABASE IF NOT EXISTS \`${dbFullName}\` CHARACTER SET utf8mb4 COLLATE ${database.collation || "utf8mb4_bin"}`,
});
}
const allTables = (yield (0, dbHandler_1.default)({
+1 -1
View File
@@ -48,7 +48,7 @@ function createTable(_a) {
})();
createTableQueryArray.push(" " + fieldEntryText + comma);
}
createTableQueryArray.push(`) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;`);
createTableQueryArray.push(`) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=${(tableSchema === null || tableSchema === void 0 ? void 0 : tableSchema.collation) || "utf8mb4_bin"};`);
const createTableQuery = createTableQueryArray.join("\n");
const newTable = yield (0, dbHandler_1.default)({
query: createTableQuery,
+20
View File
@@ -63,6 +63,26 @@ function updateTable(_a) {
if (!tableID && !isMain) {
throw new Error("Recorded Table entry not found!");
}
/**
* Handle Table Default Collation
*
* @description Update Column Collation
*/
if (tableSchema.collation) {
try {
const existingCollation = (yield (0, dbHandler_1.default)({
query: `SHOW TABLE STATUS LIKE '${tableName}'`,
config: { database: dbFullName },
}));
const existingCollationStr = existingCollation === null || existingCollation === void 0 ? void 0 : existingCollation[0].Collation;
if (existingCollationStr !== tableSchema.collation) {
yield (0, dbHandler_1.default)({
query: `ALTER TABLE \`${dbFullName}\`.\`${tableName}\` CONVERT TO CHARACTER SET utf8mb4 COLLATE ${tableSchema.collation}`,
});
}
}
catch (error) { }
}
/**
* Handle Table updates
*