Fix issues with change tracking

This commit is contained in:
2025-02-02 20:24:23 -05:00
parent 18f4970059
commit e62c6ac8ee
3 changed files with 6 additions and 4 deletions

View File

@@ -33,16 +33,15 @@ async function importPurchaseOrders(prodConnection, localConnection, incremental
status: "running",
});
// Get column names for the insert
// Get column names first
const [columns] = await localConnection.query(`
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'purchase_orders'
AND COLUMN_NAME != 'updated' -- Exclude the updated column
ORDER BY ORDINAL_POSITION
`);
const columnNames = columns
.map((col) => col.COLUMN_NAME)
.filter((name) => name !== "id");
const columnNames = columns.map(col => col.COLUMN_NAME);
// Build incremental conditions
const incrementalWhereClause = incrementalUpdate