DB 삽입위치 변경, 업데이트 로직 개선

This commit is contained in:
Lectom C Han
2025-12-10 11:35:58 +09:00
parent 452c49335e
commit c1af8f1b61
3 changed files with 49 additions and 11 deletions

View File

@@ -177,9 +177,9 @@ func copyAndUpsertCSV(ctx context.Context, conn *pgx.Conn, path, schema, table s
_ = tx.Rollback(ctx)
}()
tempTable := fmt.Sprintf("%s_import_tmp", table)
tempTable := fmt.Sprintf("%s_import_tmp_%d", table, time.Now().UnixNano())
if _, err := tx.Exec(ctx, fmt.Sprintf(`CREATE TEMP TABLE %s (LIKE %s INCLUDING ALL);`, quoteIdent(tempTable), pgx.Identifier{schema, table}.Sanitize())); err != nil {
if _, err := tx.Exec(ctx, fmt.Sprintf(`CREATE TEMP TABLE %s (LIKE %s INCLUDING ALL) ON COMMIT DROP;`, quoteIdent(tempTable), pgx.Identifier{schema, table}.Sanitize())); err != nil {
return res, err
}