Try new operation table

This commit is contained in:
WQY\qiong
2022-10-09 18:27:35 +08:00
parent 02cdbbf100
commit 69db29d981
5 changed files with 139 additions and 21 deletions

View File

@@ -1,36 +1,25 @@
create type api_operation as enum ('init', 'add', 'delete', 'update');
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)
, api_id text not null
, api_op api_operation not null
, api_object_type text not null
, api_object_id text not null
, api_object_properties text[]
, parent integer references operation(id) on delete cascade
, redo_child integer references operation(id) -- must update before delete
, redo_change_set json
, undo_change_set json
);
insert into operation (id, redo, undo, api_id, api_op, api_object_type, api_object_id) values (0, '', '', '', 'init', '', '');
insert into operation (id, redo, undo) values (0, '', '');
create table current_operation
(
id integer primary key references operation(id)
id integer primary key references operation(id) -- must update before delete
);
insert into current_operation (id) values (0);
create table snapshot_operation
(
id integer primary key references operation(id)
id integer primary key references operation(id) on delete cascade
, tag text not null unique
);
create table transaction_operation
(
id integer primary key references operation(id)
, strict boolean not null default false
);