ORDERS orders_audit_trigger AFTER INSERT OR DELETE OR UPDATE ON orders FOR EACH ROW EXECUTE PROCEDURE orders_audit_function() ORDER_ITEMS order_items_audit_trigger AFTER INSERT OR DELETE OR UPDATE ON order_items FOR EACH ROW EXECUTE PROCEDURE order_items_audit_function() Triggers
select id,status,submitted_at,shipped_at from orders where id = 85352432; -[ RECORD 1 ]+--------------------------- id | 85352432 status | x submitted_at | 2017-02-13 20:57:25+00 shipped_at | 2017-02-15 05:30:16.376+00
select order_id,change_type,changed_at, old_shipped_at,new_shipped_at from orders_audit_log where order_id = 85352432 and old_shipped_at is null and new_shipped_at is not null; -[ RECORD 1 ]--+------------------------------ order_id | 85352432 change_type | u changed_at | 2017-02-15 14:12:26.668751+00 old_shipped_at | new_shipped_at | 2017-02-15 05:30:16.376+00
More information https://wiki.postgresql.org/wiki/Audit_trigger https://wiki.postgresql.org/wiki/Audit_trigger_91plus https://github.com/2ndQuadrant/audit-trigger https://github.com/pgaudit/pgaudit
https://martinfowler.com/eaaDev/EventSourcing.html “The key to Event Sourcing is that we guarantee that all changes to the domain objects are initiated by the event objects"
http://blogs.atlassian.com/2014/08/replayable-transactions-event-sourcing-dynamodb/ "event sourcing involves storing the sequence of events that produce the current view of the entity"
http://blogs.atlassian.com/2014/08/replayable-transactions-event-sourcing-dynamodb/ "an event represents an operation or transformation from one view of the entity to another"
http://blogs.atlassian.com/2014/08/replayable-transactions-event-sourcing-dynamodb/ “events are therefore tied to a starting view or snapshot, thus making any transformation idempotent”