Re: unlimited undo/journaling
От | Glen Parker |
---|---|
Тема | Re: unlimited undo/journaling |
Дата | |
Msg-id | 004101c21d53$54ec5260$0b01a8c0@johnpark.net обсуждение исходный текст |
Ответ на | Re: unlimited undo/journaling (Richard Huxton <dev@archonet.com>) |
Список | pgsql-general |
> > so what i want is basically an unlimited undo or journalling feature > > for more or less every field. > > > > the idea should be to save the data-difference in some journalling > > table, but i'm not sure how this could be done properly. maybe > > somebody with some experience can help me here ? > > Perhaps the simplest system is to have two tables: address > and arc_address. > Use "before" triggers on address to copy the old data into > arc_address and > stamp it with a version number/timestamp. > > I've done something similar to this using a sequence to > generate unique > version numbers for me. I have too, but not using a sequence, but instead another table for version numbers: Create table trans_version (trans_id int4, version int4); Copying the current data into the archive table is quick and efficient with this method: Create table mytrans(trans_id int4, date_modified timestamp, ...); Create table arch_mytrans(version int4, trans_id int4, date_modified timestamp, ...); Then, when modifying a document: Begin; Insert into arch_mytrans select <new version #>, * from mytrans where transi_d = <trans id>; Update trans_version set version=<new version #> where trans_id = <trans id>; Commit; This allows you to add more fields to your tables without messing with your versioning code. Glen Parker glenebob@nwlink.com
В списке pgsql-general по дате отправления: