EddytorDocs & API
07 · Tables A→ZF · Load data

Upsert / merge by key

Insert, update, and delete rows in one atomic call with merge_rows - the default mutation tool.

merge_rows is the default tool for most mutations. It handles INSERT, UPDATE, and DELETE in a single atomic call - one Delta version - keyed on the primary key.

Merge

{
  "table": "eddytor.cfg_xxx.<uuid>_products",
  "comment": "Q1 price update and product retirement",
  "rows": [
    { "_operation": "INSERT", "product_id": "P200", "name": "New Item", "category": "Clothing", "price": 19.99, "status": "active" },
    { "_operation": "UPDATE", "product_id": "P001", "price": 34.99 },
    { "_operation": "DELETE", "product_id": "P050" }
  ]
}
eddytor merge table eddytor sales orders --file ./changes.csv

The rules

Heads up

_operation is required on every row in merge_rows - forgetting it errors. UPDATE rows need only the PK + changed fields (omitted columns keep their values). DELETE rows need only the PK. The whole batch is atomic - if any row violates a constraint, the entire batch is rejected; partial success is impossible by design.

Add a comment - it's recorded on the Delta version, so the history tells you why a change was made.

Data-sync pattern

  1. query_rows → understand current state.
  2. Compute the diff → which rows INSERT / UPDATE / DELETE.
  3. merge_rows with a comment → one atomic version.
  4. validate_constraints + validate_domain_values.

Next

On this page