CREATE TABLE OPERATION
(
  ID SERIAL PRIMARY KEY
, REDO TEXT NOT NULL
, UNDO TEXT NOT NULL
, PARENT INTEGER REFERENCES OPERATION(ID)
, REDOCHILD INTEGER REFERENCES OPERATION(ID)
);

INSERT INTO OPERATION (ID, REDO, UNDO) VALUES (0, '', '');

CREATE TABLE CURRENTOPERATION
(
  ID INTEGER PRIMARY KEY REFERENCES OPERATION(ID)
);

INSERT INTO CURRENTOPERATION (ID) VALUES (0);
