CREATE TABLE OPERATION
(
  ID SERIAL PRIMARY KEY
, Redo TEXT NOT NULL
, Undo TEXT NOT NULL
, Parent INTEGER REFERENCES OPERATION(ID)
, Redo_Child INTEGER REFERENCES OPERATION(ID)
);

INSERT INTO OPERATION (ID, Redo, Undo) VALUES (0, '', '');

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

INSERT INTO CURRENT_OPERATION (ID) VALUES (0);

CREATE TABLE SNAPSHOT_OPERATION
(
  ID INTEGER PRIMARY KEY REFERENCES OPERATION(ID)
, Tag TEXT NOT NULL UNIQUE
);

CREATE TABLE TRANSACTION_OPERATION
(
  ID INTEGER PRIMARY KEY REFERENCES OPERATION(ID)
, STRICT BOOLEAN NOT NULL DEFAULT FALSE
);
