Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b47a5abd26 | |||
| fcd8310ed8 |
@ -785,7 +785,8 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
@ -793,6 +794,7 @@
|
|||||||
" modified_by",
|
" modified_by",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{",
|
" '{",
|
||||||
" \"first_name\":\"IncompleteFirst\",",
|
" \"first_name\":\"IncompleteFirst\",",
|
||||||
" \"last_name\":\"IncompleteLast\",",
|
" \"last_name\":\"IncompleteLast\",",
|
||||||
@ -816,6 +818,11 @@
|
|||||||
" \"modified_at\":\"{{timestamp}}\",",
|
" \"modified_at\":\"{{timestamp}}\",",
|
||||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||||
" \"type\":\"person\"",
|
" \"type\":\"person\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"first_name\":\"IncompleteFirst\",",
|
||||||
|
" \"last_name\":\"IncompleteLast\",",
|
||||||
|
" \"type\":\"person\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
]
|
]
|
||||||
@ -872,7 +879,8 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
@ -881,6 +889,9 @@
|
|||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" '{",
|
" '{",
|
||||||
|
" \"contact_id\":\"old-contact\"",
|
||||||
|
" }',",
|
||||||
|
" '{",
|
||||||
" \"contact_id\":\"abc-contact\",",
|
" \"contact_id\":\"abc-contact\",",
|
||||||
" \"type\":\"person\"",
|
" \"type\":\"person\"",
|
||||||
" }',",
|
" }',",
|
||||||
@ -893,10 +904,6 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"SELECT pg_notify('entity', '{",
|
"SELECT pg_notify('entity', '{",
|
||||||
" \"changes\":{",
|
|
||||||
" \"contact_id\":\"abc-contact\",",
|
|
||||||
" \"type\":\"person\"",
|
|
||||||
" },",
|
|
||||||
" \"complete\":{",
|
" \"complete\":{",
|
||||||
" \"contact_id\":\"abc-contact\",",
|
" \"contact_id\":\"abc-contact\",",
|
||||||
" \"date_of_birth\":\"1990-01-01T00:00:00Z\",",
|
" \"date_of_birth\":\"1990-01-01T00:00:00Z\",",
|
||||||
@ -907,6 +914,13 @@
|
|||||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||||
" \"pronouns\":\"they/them\",",
|
" \"pronouns\":\"they/them\",",
|
||||||
" \"type\":\"person\"",
|
" \"type\":\"person\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"contact_id\":\"abc-contact\",",
|
||||||
|
" \"type\":\"person\"",
|
||||||
|
" },",
|
||||||
|
" \"old\":{",
|
||||||
|
" \"contact_id\":\"old-contact\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
]
|
]
|
||||||
@ -959,7 +973,8 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
@ -968,6 +983,10 @@
|
|||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
" '{",
|
" '{",
|
||||||
|
" \"first_name\":\"OldFirst\",",
|
||||||
|
" \"last_name\":\"OldLast\"",
|
||||||
|
" }',",
|
||||||
|
" '{",
|
||||||
" \"first_name\":\"NewFirst\",",
|
" \"first_name\":\"NewFirst\",",
|
||||||
" \"last_name\":\"NewLast\",",
|
" \"last_name\":\"NewLast\",",
|
||||||
" \"type\":\"person\"",
|
" \"type\":\"person\"",
|
||||||
@ -981,11 +1000,6 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"SELECT pg_notify('entity', '{",
|
"SELECT pg_notify('entity', '{",
|
||||||
" \"changes\":{",
|
|
||||||
" \"first_name\":\"NewFirst\",",
|
|
||||||
" \"last_name\":\"NewLast\",",
|
|
||||||
" \"type\":\"person\"",
|
|
||||||
" },",
|
|
||||||
" \"complete\":{",
|
" \"complete\":{",
|
||||||
" \"first_name\":\"NewFirst\",",
|
" \"first_name\":\"NewFirst\",",
|
||||||
" \"id\":\"11111111-1111-1111-1111-111111111111\",",
|
" \"id\":\"11111111-1111-1111-1111-111111111111\",",
|
||||||
@ -993,6 +1007,15 @@
|
|||||||
" \"modified_at\":\"2026-03-10T00:00:00Z\",",
|
" \"modified_at\":\"2026-03-10T00:00:00Z\",",
|
||||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||||
" \"type\":\"person\"",
|
" \"type\":\"person\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"first_name\":\"NewFirst\",",
|
||||||
|
" \"last_name\":\"NewLast\",",
|
||||||
|
" \"type\":\"person\"",
|
||||||
|
" },",
|
||||||
|
" \"old\":{",
|
||||||
|
" \"first_name\":\"OldFirst\",",
|
||||||
|
" \"last_name\":\"OldLast\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
]
|
]
|
||||||
@ -1079,7 +1102,8 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
@ -1087,6 +1111,7 @@
|
|||||||
" modified_by",
|
" modified_by",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{",
|
" '{",
|
||||||
" \"date_of_birth\":\"1990-01-01T00:00:00Z\",",
|
" \"date_of_birth\":\"1990-01-01T00:00:00Z\",",
|
||||||
" \"first_name\":\"John\",",
|
" \"first_name\":\"John\",",
|
||||||
@ -1114,6 +1139,13 @@
|
|||||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||||
" \"pronouns\":\"\",",
|
" \"pronouns\":\"\",",
|
||||||
" \"type\":\"person\"",
|
" \"type\":\"person\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"date_of_birth\":\"1990-01-01T00:00:00Z\",",
|
||||||
|
" \"first_name\":\"John\",",
|
||||||
|
" \"last_name\":\"Doe\",",
|
||||||
|
" \"pronouns\":\"\",",
|
||||||
|
" \"type\":\"person\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
]
|
]
|
||||||
@ -1192,7 +1224,8 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
@ -1200,6 +1233,7 @@
|
|||||||
" modified_by",
|
" modified_by",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{",
|
" '{",
|
||||||
" \"date_of_birth\":\"2000-01-01\",",
|
" \"date_of_birth\":\"2000-01-01\",",
|
||||||
" \"first_name\":\"Bob\",",
|
" \"first_name\":\"Bob\",",
|
||||||
@ -1247,7 +1281,8 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
@ -1255,6 +1290,7 @@
|
|||||||
" modified_by",
|
" modified_by",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{",
|
" '{",
|
||||||
" \"customer_id\":\"{{uuid:customer_id}}\",",
|
" \"customer_id\":\"{{uuid:customer_id}}\",",
|
||||||
" \"total\":100.0,",
|
" \"total\":100.0,",
|
||||||
@ -1278,6 +1314,11 @@
|
|||||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||||
" \"total\":100.0,",
|
" \"total\":100.0,",
|
||||||
" \"type\":\"order\"",
|
" \"type\":\"order\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"customer_id\":\"{{uuid:customer_id}}\",",
|
||||||
|
" \"total\":100.0,",
|
||||||
|
" \"type\":\"order\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
],
|
],
|
||||||
@ -1293,6 +1334,12 @@
|
|||||||
" \"modified_at\":\"{{timestamp}}\",",
|
" \"modified_at\":\"{{timestamp}}\",",
|
||||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||||
" \"type\":\"person\"",
|
" \"type\":\"person\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"date_of_birth\":\"2000-01-01\",",
|
||||||
|
" \"first_name\":\"Bob\",",
|
||||||
|
" \"last_name\":\"Smith\",",
|
||||||
|
" \"type\":\"person\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
]
|
]
|
||||||
@ -1388,7 +1435,8 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
@ -1396,6 +1444,7 @@
|
|||||||
" modified_by",
|
" modified_by",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{",
|
" '{",
|
||||||
" \"order_id\":\"abc\",",
|
" \"order_id\":\"abc\",",
|
||||||
" \"price\":99.0,",
|
" \"price\":99.0,",
|
||||||
@ -1411,7 +1460,8 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
@ -1419,6 +1469,7 @@
|
|||||||
" modified_by",
|
" modified_by",
|
||||||
")",
|
")",
|
||||||
"VALUES (",
|
"VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{",
|
" '{",
|
||||||
" \"total\":99.0,",
|
" \"total\":99.0,",
|
||||||
" \"type\":\"order\"",
|
" \"type\":\"order\"",
|
||||||
@ -1440,6 +1491,10 @@
|
|||||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||||
" \"total\":99.0,",
|
" \"total\":99.0,",
|
||||||
" \"type\":\"order\"",
|
" \"type\":\"order\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"total\":99.0,",
|
||||||
|
" \"type\":\"order\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
],
|
],
|
||||||
@ -1455,6 +1510,12 @@
|
|||||||
" \"price\":99.0,",
|
" \"price\":99.0,",
|
||||||
" \"product\":\"Widget\",",
|
" \"product\":\"Widget\",",
|
||||||
" \"type\":\"order_line\"",
|
" \"type\":\"order_line\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"order_id\":\"abc\",",
|
||||||
|
" \"price\":99.0,",
|
||||||
|
" \"product\":\"Widget\",",
|
||||||
|
" \"type\":\"order_line\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
]
|
]
|
||||||
@ -1572,13 +1633,15 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
" modified_at,",
|
" modified_at,",
|
||||||
" modified_by",
|
" modified_by",
|
||||||
") VALUES (",
|
") VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{\"number\":\"555-0001\",\"type\":\"phone_number\"}',",
|
" '{\"number\":\"555-0001\",\"type\":\"phone_number\"}',",
|
||||||
" '{{uuid:phone1_id}}',",
|
" '{{uuid:phone1_id}}',",
|
||||||
" '{{uuid}}',",
|
" '{{uuid}}',",
|
||||||
@ -1626,13 +1689,15 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
" modified_at,",
|
" modified_at,",
|
||||||
" modified_by",
|
" modified_by",
|
||||||
") VALUES (",
|
") VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{",
|
" '{",
|
||||||
" \"is_primary\":true,",
|
" \"is_primary\":true,",
|
||||||
" \"source_id\":\"{{uuid:person_id}}\",",
|
" \"source_id\":\"{{uuid:person_id}}\",",
|
||||||
@ -1674,13 +1739,15 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
" modified_at,",
|
" modified_at,",
|
||||||
" modified_by",
|
" modified_by",
|
||||||
") VALUES (",
|
") VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{",
|
" '{",
|
||||||
" \"number\":\"555-0002\",",
|
" \"number\":\"555-0002\",",
|
||||||
" \"type\":\"phone_number\"",
|
" \"type\":\"phone_number\"",
|
||||||
@ -1731,13 +1798,15 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
" modified_at,",
|
" modified_at,",
|
||||||
" modified_by",
|
" modified_by",
|
||||||
") VALUES (",
|
") VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{",
|
" '{",
|
||||||
" \"is_primary\":false,",
|
" \"is_primary\":false,",
|
||||||
" \"source_id\":\"{{uuid:person_id}}\",",
|
" \"source_id\":\"{{uuid:person_id}}\",",
|
||||||
@ -1779,13 +1848,15 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
" modified_at,",
|
" modified_at,",
|
||||||
" modified_by",
|
" modified_by",
|
||||||
") VALUES (",
|
") VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{",
|
" '{",
|
||||||
" \"address\":\"test@example.com\",",
|
" \"address\":\"test@example.com\",",
|
||||||
" \"type\":\"email_address\"",
|
" \"type\":\"email_address\"",
|
||||||
@ -1836,13 +1907,15 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
" modified_at,",
|
" modified_at,",
|
||||||
" modified_by",
|
" modified_by",
|
||||||
") VALUES (",
|
") VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{",
|
" '{",
|
||||||
" \"is_primary\":false,",
|
" \"is_primary\":false,",
|
||||||
" \"source_id\":\"{{uuid:person_id}}\",",
|
" \"source_id\":\"{{uuid:person_id}}\",",
|
||||||
@ -1860,13 +1933,15 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
" modified_at,",
|
" modified_at,",
|
||||||
" modified_by",
|
" modified_by",
|
||||||
") VALUES (",
|
") VALUES (",
|
||||||
|
" NULL,",
|
||||||
" '{",
|
" '{",
|
||||||
" \"first_name\":\"Relation\",",
|
" \"first_name\":\"Relation\",",
|
||||||
" \"last_name\":\"Test\",",
|
" \"last_name\":\"Test\",",
|
||||||
@ -1890,6 +1965,11 @@
|
|||||||
" \"modified_at\":\"{{timestamp}}\",",
|
" \"modified_at\":\"{{timestamp}}\",",
|
||||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||||
" \"type\":\"person\"",
|
" \"type\":\"person\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"first_name\":\"Relation\",",
|
||||||
|
" \"last_name\":\"Test\",",
|
||||||
|
" \"type\":\"person\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
],
|
],
|
||||||
@ -1907,6 +1987,14 @@
|
|||||||
" \"target_id\":\"{{uuid:phone1_id}}\",",
|
" \"target_id\":\"{{uuid:phone1_id}}\",",
|
||||||
" \"target_type\":\"phone_number\",",
|
" \"target_type\":\"phone_number\",",
|
||||||
" \"type\":\"contact\"",
|
" \"type\":\"contact\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"is_primary\":true,",
|
||||||
|
" \"source_id\":\"{{uuid:person_id}}\",",
|
||||||
|
" \"source_type\":\"person\",",
|
||||||
|
" \"target_id\":\"{{uuid:phone1_id}}\",",
|
||||||
|
" \"target_type\":\"phone_number\",",
|
||||||
|
" \"type\":\"contact\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
],
|
],
|
||||||
@ -1920,6 +2008,10 @@
|
|||||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||||
" \"number\":\"555-0001\",",
|
" \"number\":\"555-0001\",",
|
||||||
" \"type\":\"phone_number\"",
|
" \"type\":\"phone_number\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"number\":\"555-0001\",",
|
||||||
|
" \"type\":\"phone_number\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
],
|
],
|
||||||
@ -1937,6 +2029,14 @@
|
|||||||
" \"target_id\":\"{{uuid:phone2_id}}\",",
|
" \"target_id\":\"{{uuid:phone2_id}}\",",
|
||||||
" \"target_type\":\"phone_number\",",
|
" \"target_type\":\"phone_number\",",
|
||||||
" \"type\":\"contact\"",
|
" \"type\":\"contact\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"is_primary\":false,",
|
||||||
|
" \"source_id\":\"{{uuid:person_id}}\",",
|
||||||
|
" \"source_type\":\"person\",",
|
||||||
|
" \"target_id\":\"{{uuid:phone2_id}}\",",
|
||||||
|
" \"target_type\":\"phone_number\",",
|
||||||
|
" \"type\":\"contact\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
],
|
],
|
||||||
@ -1950,6 +2050,10 @@
|
|||||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||||
" \"number\":\"555-0002\",",
|
" \"number\":\"555-0002\",",
|
||||||
" \"type\":\"phone_number\"",
|
" \"type\":\"phone_number\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"number\":\"555-0002\",",
|
||||||
|
" \"type\":\"phone_number\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
],
|
],
|
||||||
@ -1967,6 +2071,14 @@
|
|||||||
" \"target_id\":\"{{uuid:email1_id}}\",",
|
" \"target_id\":\"{{uuid:email1_id}}\",",
|
||||||
" \"target_type\":\"email_address\",",
|
" \"target_type\":\"email_address\",",
|
||||||
" \"type\":\"contact\"",
|
" \"type\":\"contact\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"is_primary\":false,",
|
||||||
|
" \"source_id\":\"{{uuid:person_id}}\",",
|
||||||
|
" \"source_type\":\"person\",",
|
||||||
|
" \"target_id\":\"{{uuid:email1_id}}\",",
|
||||||
|
" \"target_type\":\"email_address\",",
|
||||||
|
" \"type\":\"contact\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
],
|
],
|
||||||
@ -1980,6 +2092,10 @@
|
|||||||
" \"modified_at\":\"{{timestamp}}\",",
|
" \"modified_at\":\"{{timestamp}}\",",
|
||||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||||
" \"type\":\"email_address\"",
|
" \"type\":\"email_address\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"address\":\"test@example.com\",",
|
||||||
|
" \"type\":\"email_address\"",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
]
|
]
|
||||||
@ -2023,13 +2139,17 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"INSERT INTO agreego.change (",
|
"INSERT INTO agreego.change (",
|
||||||
" changes,",
|
" \"old\",",
|
||||||
|
" \"new\",",
|
||||||
" entity_id,",
|
" entity_id,",
|
||||||
" id,",
|
" id,",
|
||||||
" kind,",
|
" kind,",
|
||||||
" modified_at,",
|
" modified_at,",
|
||||||
" modified_by",
|
" modified_by",
|
||||||
") VALUES (",
|
") VALUES (",
|
||||||
|
" '{",
|
||||||
|
" \"archived\":false",
|
||||||
|
" }',",
|
||||||
" '{\"archived\":true,\"type\":\"person\"}',",
|
" '{\"archived\":true,\"type\":\"person\"}',",
|
||||||
" 'abc-archived',",
|
" 'abc-archived',",
|
||||||
" '{{uuid}}',",
|
" '{{uuid}}',",
|
||||||
@ -2040,8 +2160,6 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
"SELECT pg_notify('entity', '{",
|
"SELECT pg_notify('entity', '{",
|
||||||
" \"changes\":{",
|
|
||||||
" \"archived\":true,\"type\":\"person\"},",
|
|
||||||
" \"complete\":{",
|
" \"complete\":{",
|
||||||
" \"archived\":true,",
|
" \"archived\":true,",
|
||||||
" \"first_name\":\"ArchivedFirst\",",
|
" \"first_name\":\"ArchivedFirst\",",
|
||||||
@ -2050,6 +2168,13 @@
|
|||||||
" \"modified_at\":\"{{timestamp}}\",",
|
" \"modified_at\":\"{{timestamp}}\",",
|
||||||
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
" \"modified_by\":\"00000000-0000-0000-0000-000000000000\",",
|
||||||
" \"type\":\"person\"",
|
" \"type\":\"person\"",
|
||||||
|
" },",
|
||||||
|
" \"new\":{",
|
||||||
|
" \"archived\":true,",
|
||||||
|
" \"type\":\"person\"",
|
||||||
|
" },",
|
||||||
|
" \"old\":{",
|
||||||
|
" \"archived\":false",
|
||||||
" }",
|
" }",
|
||||||
" }')"
|
" }')"
|
||||||
]
|
]
|
||||||
|
|||||||
@ -694,7 +694,8 @@ impl Merger {
|
|||||||
let id_str = entity_fields.get("id").unwrap();
|
let id_str = entity_fields.get("id").unwrap();
|
||||||
let type_name = entity_fields.get("type").unwrap();
|
let type_name = entity_fields.get("type").unwrap();
|
||||||
|
|
||||||
let mut changes = serde_json::Map::new();
|
let mut old_vals = serde_json::Map::new();
|
||||||
|
let mut new_vals = serde_json::Map::new();
|
||||||
let is_update = change_kind == "update" || change_kind == "delete";
|
let is_update = change_kind == "update" || change_kind == "delete";
|
||||||
|
|
||||||
if !is_update {
|
if !is_update {
|
||||||
@ -707,7 +708,7 @@ impl Merger {
|
|||||||
];
|
];
|
||||||
for (k, v) in entity_fields {
|
for (k, v) in entity_fields {
|
||||||
if !system_keys.contains(k) {
|
if !system_keys.contains(k) {
|
||||||
changes.insert(k.clone(), v.clone());
|
new_vals.insert(k.clone(), v.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -724,12 +725,13 @@ impl Merger {
|
|||||||
if let Some(fetched) = entity_fetched {
|
if let Some(fetched) = entity_fetched {
|
||||||
let old_val = fetched.get(k).unwrap_or(&Value::Null);
|
let old_val = fetched.get(k).unwrap_or(&Value::Null);
|
||||||
if v != old_val {
|
if v != old_val {
|
||||||
changes.insert(k.clone(), v.clone());
|
new_vals.insert(k.clone(), v.clone());
|
||||||
|
old_vals.insert(k.clone(), old_val.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
changes.insert("type".to_string(), type_name.clone());
|
new_vals.insert("type".to_string(), type_name.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut complete = entity_fields.clone();
|
let mut complete = entity_fields.clone();
|
||||||
@ -743,15 +745,25 @@ impl Merger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let new_val_obj = Value::Object(new_vals);
|
||||||
|
let old_val_obj = if old_vals.is_empty() {
|
||||||
|
Value::Null
|
||||||
|
} else {
|
||||||
|
Value::Object(old_vals)
|
||||||
|
};
|
||||||
|
|
||||||
let mut notification = serde_json::Map::new();
|
let mut notification = serde_json::Map::new();
|
||||||
notification.insert("complete".to_string(), Value::Object(complete));
|
notification.insert("complete".to_string(), Value::Object(complete));
|
||||||
if is_update {
|
notification.insert("new".to_string(), new_val_obj.clone());
|
||||||
notification.insert("changes".to_string(), Value::Object(changes.clone()));
|
|
||||||
|
if old_val_obj != Value::Null {
|
||||||
|
notification.insert("old".to_string(), old_val_obj.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let change_sql = format!(
|
let change_sql = format!(
|
||||||
"INSERT INTO agreego.change (changes, entity_id, id, kind, modified_at, modified_by) VALUES ({}, {}, {}, {}, {}, {})",
|
"INSERT INTO agreego.change (\"old\", \"new\", entity_id, id, kind, modified_at, modified_by) VALUES ({}, {}, {}, {}, {}, {}, {})",
|
||||||
Self::quote_literal(&Value::Object(changes)),
|
Self::quote_literal(&old_val_obj),
|
||||||
|
Self::quote_literal(&new_val_obj),
|
||||||
Self::quote_literal(id_str),
|
Self::quote_literal(id_str),
|
||||||
Self::quote_literal(&Value::String(uuid::Uuid::new_v4().to_string())),
|
Self::quote_literal(&Value::String(uuid::Uuid::new_v4().to_string())),
|
||||||
Self::quote_literal(&Value::String(change_kind.to_string())),
|
Self::quote_literal(&Value::String(change_kind.to_string())),
|
||||||
|
|||||||
Reference in New Issue
Block a user