fix: upsert logic
This commit is contained in:
parent
8b6f648c08
commit
3a901077c9
|
@ -195,15 +195,14 @@ pgInsert({
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export async function pgUpsert({ contents, schema, tableName }) {
|
export async function pgUpsert({ contents, schema, tableName }) {
|
||||||
|
|
||||||
|
|
||||||
if (tableWhiteList.includes(`${schema}.${tableName}`)) {
|
if (tableWhiteList.includes(`${schema}.${tableName}`)) {
|
||||||
if (schema == "latest") {
|
if (schema == "latest") {
|
||||||
await dropTable(schema, tableName);
|
await runPgCommand({ command: dropTable(schema, tableName), pool: readWritePool })
|
||||||
await buildMetaforecastTable(schema, tableName);
|
await runPgCommand({ command: buildMetaforecastTable(schema, tableName), pool: readWritePool })
|
||||||
await createUniqueIndex(schema, tableName)
|
await runPgCommand({ command: createUniqueIndex(schema, tableName), pool: readWritePool })
|
||||||
}
|
}
|
||||||
console.log(`Inserting into postgres table ${schema}.${tableName}`)
|
console.log(`Upserting into postgres table ${schema}.${tableName}`)
|
||||||
|
console.log({ contents, schema, tableName })
|
||||||
let i = 0
|
let i = 0
|
||||||
for (let datum of contents) {
|
for (let datum of contents) {
|
||||||
await pgInsert({ datum, schema, tableName })
|
await pgInsert({ datum, schema, tableName })
|
||||||
|
|
Loading…
Reference in New Issue
Block a user