This commit is contained in:
Benjamin Toby
2025-06-01 11:39:56 +01:00
parent b28b05956b
commit 9b7c98cff6
18 changed files with 151 additions and 54 deletions
+5 -4
View File
@@ -58,22 +58,23 @@ function createDbFromSchema(_a) {
});
for (let tb = 0; tb < allTables.length; tb++) {
const { TABLE_NAME } = allTables[tb];
const targetTableSchema = tables.find((_table) => _table.tableName === TABLE_NAME);
/**
* @description Check if TABLE_NAME is part of the tables contained
* in the user schema JSON. If it's not, the table is either deleted
* or the table name has been recently changed
*/
if (!tables.filter((_table) => _table.tableName === TABLE_NAME)[0]) {
const oldTableFilteredArray = tables.filter((_table) => _table.tableNameOld &&
if (!targetTableSchema) {
const oldTable = tables.find((_table) => _table.tableNameOld &&
_table.tableNameOld === TABLE_NAME);
/**
* @description Check if this table has been recently renamed. Rename
* table id true. Drop table if false
*/
if (oldTableFilteredArray && oldTableFilteredArray[0]) {
if (oldTable) {
console.log("Renaming Table");
yield (0, varDatabaseDbHandler_1.default)({
queryString: `RENAME TABLE \`${dbFullName}\`.\`${oldTableFilteredArray[0].tableNameOld}\` TO \`${oldTableFilteredArray[0].tableName}\``,
queryString: `RENAME TABLE \`${dbFullName}\`.\`${oldTable.tableNameOld}\` TO \`${oldTable.tableName}\``,
});
}
else {