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
+3 -1
View File
@@ -63,7 +63,9 @@ export default async function createTable({
}
createTableQueryArray.push(
`) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;`
`) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=${
tableSchema?.collation || "utf8mb4_bin"
};`
);
const createTableQuery = createTableQueryArray.join("\n");
+22
View File
@@ -92,6 +92,28 @@ export default async function updateTable({
throw new Error("Recorded Table entry not found!");
}
/**
* Handle Table Default Collation
*
* @description Update Column Collation
*/
if (tableSchema.collation) {
try {
const existingCollation = (await dbHandler({
query: `SHOW TABLE STATUS LIKE '${tableName}'`,
config: { database: dbFullName },
})) as any[];
const existingCollationStr = existingCollation?.[0].Collation;
if (existingCollationStr !== tableSchema.collation) {
await dbHandler({
query: `ALTER TABLE \`${dbFullName}\`.\`${tableName}\` CONVERT TO CHARACTER SET utf8mb4 COLLATE ${tableSchema.collation}`,
});
}
} catch (error) {}
}
/**
* Handle Table updates
*