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.csvThe 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
query_rows→ understand current state.- Compute the diff → which rows INSERT / UPDATE / DELETE.
merge_rowswith acomment→ one atomic version.validate_constraints+validate_domain_values.