Bugfix
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user