Revision Workflow-

Begin txn
rev = new revision
stack.head = revision

On INSERT:

  asssert registration.stack.head.is_committed == 0;

  registration_history = registration
  registration_history.created_in_revision = registration.stack.head

On DELETE:

  registration_history.deleted_in_revision = registration.stack.head

revision.is_committed = 1
Commit txn


# SAMPLE TRIGGERS...

CREATE TRIGGER AFTER INSERT ON registration
BEGIN

       INSERT INTO registration_history SELECT new.*, NULL, NULL from new;
       UPDATE registration_history SET created_in_revision = (SELECT max id FROM revision WHERE revision.stack = new.stack);

END;


CREATE TRIGGER AFTER DELETE ON registration
BEGIN

       INSERT INTO registration_history SELECT new.*, NULL, NULL from new;
       UPDATE registration_history SET deleted_in_revision = (SELECT max id FROM revision WHERE revision.stack = new.stack);

END;


