Skip to main content

Upsert

PostgreSQL Plugin – Upsert

Summary (SEO Meta Description):
The PostgreSQL Upsert action in WeHub inserts new rows or updates existing ones if conflicts occur.
It simplifies workflows by handling both insert and update operations in one step.


Overview

The Upsert action combines Insert and Update logic into a single step.
If a row with a matching key already exists, it will be updated.
If not, a new row will be inserted.

This is especially useful for maintaining idempotent workflows, avoiding duplicate records, and ensuring data stays consistent across multiple runs.

Typical Use Cases:

  • Maintain a user profile table (insert new users, update existing users)
  • Sync external system records without worrying about duplicates
  • Manage inventory (insert new items, update stock levels)
  • Ensure workflow logs stay consistent on retries

⚙️ Action: Upsert

Configuration Options:

FieldTypeDescription
LabelStringCustom name for the action.
Select ConnectionEnumChoose or create a PostgreSQL connection.
Table NameEnumSelect the table for the upsert.
ColumnsListDefine the columns and values to insert or update.
MapObjectMap workflow fields to table columns.
ConditionStringCondition for resolving conflicts (e.g., matching primary keys).
Inputs (Manual)MixedDefine input parameters manually with types (NUMBER, STRING, BOOLEAN, etc.).
Inputs SchemaSchemaMap input parameters using schema.

FAQ

Q: How does PostgreSQL decide when to insert or update?
A: If the row does not exist, it’s inserted. If a row with the same unique key/primary key exists, it’s updated.

Q: Can I specify which fields get updated on conflict?
A: Yes. You can define columns in the Map section to control which fields are updated.

Q: What happens if I don’t provide a condition?
A: PostgreSQL will rely on the table’s primary key or unique index to determine conflicts.


Keywords: WeHub PostgreSQL Plugin, PostgreSQL Upsert, Insert or Update, Database Workflow Automation