Updates
This commit is contained in:
@@ -75,15 +75,17 @@ export default async function createDbFromSchema({
|
||||
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(
|
||||
if (!targetTableSchema) {
|
||||
const oldTable = tables.find(
|
||||
(_table) =>
|
||||
_table.tableNameOld &&
|
||||
_table.tableNameOld === TABLE_NAME
|
||||
@@ -93,10 +95,10 @@ export default async function createDbFromSchema({
|
||||
* @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");
|
||||
await varDatabaseDbHandler({
|
||||
queryString: `RENAME TABLE \`${dbFullName}\`.\`${oldTableFilteredArray[0].tableNameOld}\` TO \`${oldTableFilteredArray[0].tableName}\``,
|
||||
queryString: `RENAME TABLE \`${dbFullName}\`.\`${oldTable.tableNameOld}\` TO \`${oldTable.tableName}\``,
|
||||
});
|
||||
} else {
|
||||
console.log(`Dropping Table from ${dbFullName}`);
|
||||
|
||||
Reference in New Issue
Block a user