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:
| Field | Type | Description | 
|---|---|---|
| Label | String | Custom name for the action. | 
| Select Connection | Enum | Choose or create a PostgreSQL connection. | 
| Table Name | Enum | Select the table for the upsert. | 
| Columns | List | Define the columns and values to insert or update. | 
| Map | Object | Map workflow fields to table columns. | 
| Condition | String | Condition for resolving conflicts (e.g., matching primary keys). | 
| Inputs (Manual) | Mixed | Define input parameters manually with types ( NUMBER,STRING,BOOLEAN, etc.). | 
| Inputs Schema | Schema | Map 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