어떠냐? 보기 좋지 않냐?


다 JSON으로 박아버림. 오늘은 그만하고 내일은 immutable records 구현해야지. 


이게 회계에 쓸거라 insert와 select만 하고 update와 delete는 안씀. 뭐가 잘못되었다 하면 그 날짜로 되돌아가서 거기서 부터 새로 다시 하게 하려면 immutable이 되줘야함




accountingdb=> select * from audit;

 id |             ctime             | kind |     context      | tname |                                                           details                                                           

----+-------------------------------+------+------------------+-------+-----------------------------------------------------------------------------------------------------------------------------

  5 | 2015-06-22 22:05:50.160862+9 | I    | {"a": 1, "b": 2} | foo   | {"q": "insert into  foo (text) values ('abc');", "nv": {"id": 13, "text": "abc"}, "ov": null}

  6 | 2015-06-22 22:06:37.683603+9 | I    | {"a": 1, "b": 2} | foo   | {"q": "insert into  foo (text) values ('def');", "nv": {"id": 14, "text": "def"}, "ov": null}

  7 | 2015-06-22 22:07:07.487266+9 | D    | {"a": 1, "b": 2} | foo   | {"q": "delete from  foo where text = 'abc';", "nv": null, "ov": {"id": 1, "text": "abc"}}

  8 | 2015-06-22 22:07:07.487266+9 | D    | {"a": 1, "b": 2} | foo   | {"q": "delete from  foo where text = 'abc';", "nv": null, "ov": {"id": 13, "text": "abc"}}

  9 | 2015-06-22 22:09:00.065237+9 | U    | {"a": 1, "b": 2} | foo   | {"q": "update  foo set text = 'kkk' where text = 'def';", "nv": null, "ov": null}

 10 | 2015-06-22 22:11:36.161649+9 | U    | {"a": 1, "b": 2} | foo   | {"q": "update  foo set text = 'def' where text = 'kkk';", "nv": {"id": 14, "text": "def"}, "ov": {"id": 14, "text": "kkk"}}

(6 rows)