From 058a5a107fe6c3ec7090fa78d0bd3e396693d54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Wed, 26 Mar 2025 10:25:12 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=20workflow=20=E7=9A=84?= =?UTF-8?q?=E5=88=9B=E5=BB=BAsql=20=E6=B2=A1=E6=9C=89=E5=8C=85=E5=90=ABund?= =?UTF-8?q?o=5Flog=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/sql/oracle/oracle_ry_workflow.sql | 28 +++++++++++++++++++ ...l_ry_config.sql => postgres_ry_config.sql} | 0 script/sql/postgres/postgres_ry_workflow.sql | 28 +++++++++++++++++++ script/sql/ry-workflow.sql | 14 ++++++++++ 4 files changed, 70 insertions(+) rename script/sql/postgres/{postgresql_ry_config.sql => postgres_ry_config.sql} (100%) diff --git a/script/sql/oracle/oracle_ry_workflow.sql b/script/sql/oracle/oracle_ry_workflow.sql index babe30b4..62563d19 100644 --- a/script/sql/oracle/oracle_ry_workflow.sql +++ b/script/sql/oracle/oracle_ry_workflow.sql @@ -363,3 +363,31 @@ COMMENT ON COLUMN test_leave.create_by IS '创建者'; COMMENT ON COLUMN test_leave.create_time IS '创建时间'; COMMENT ON COLUMN test_leave.update_by IS '更新者'; COMMENT ON COLUMN test_leave.update_time IS '更新时间'; + + +-- for AT mode you must to init this sql for you business database. the seata server not need it. +CREATE TABLE undo_log +( + id NUMBER(19) NOT NULL, + branch_id NUMBER(19) NOT NULL, + xid VARCHAR2(128) NOT NULL, + context VARCHAR2(128) NOT NULL, + rollback_info BLOB NOT NULL, + log_status NUMBER(10) NOT NULL, + log_created TIMESTAMP(0) NOT NULL, + log_modified TIMESTAMP(0) NOT NULL, + PRIMARY KEY (id), + CONSTRAINT ux_undo_log UNIQUE (xid, branch_id) +); +CREATE INDEX ix_log_created ON undo_log(log_created); +COMMENT ON TABLE undo_log IS 'AT transaction mode undo table'; +COMMENT ON COLUMN undo_log.branch_id is 'branch transaction id'; +COMMENT ON COLUMN undo_log.xid is 'global transaction id'; +COMMENT ON COLUMN undo_log.context is 'undo_log context,such as serialization'; +COMMENT ON COLUMN undo_log.rollback_info is 'rollback info'; +COMMENT ON COLUMN undo_log.log_status is '0:normal status,1:defense status'; +COMMENT ON COLUMN undo_log.log_created is 'create datetime'; +COMMENT ON COLUMN undo_log.log_modified is 'modify datetime'; + +-- Generate ID using sequence and trigger +CREATE SEQUENCE UNDO_LOG_SEQ START WITH 1 INCREMENT BY 1; diff --git a/script/sql/postgres/postgresql_ry_config.sql b/script/sql/postgres/postgres_ry_config.sql similarity index 100% rename from script/sql/postgres/postgresql_ry_config.sql rename to script/sql/postgres/postgres_ry_config.sql diff --git a/script/sql/postgres/postgres_ry_workflow.sql b/script/sql/postgres/postgres_ry_workflow.sql index a7e05dbe..8574118f 100644 --- a/script/sql/postgres/postgres_ry_workflow.sql +++ b/script/sql/postgres/postgres_ry_workflow.sql @@ -356,3 +356,31 @@ COMMENT ON COLUMN test_leave.create_by IS '创建者'; COMMENT ON COLUMN test_leave.create_time IS '创建时间'; COMMENT ON COLUMN test_leave.update_by IS '更新者'; COMMENT ON COLUMN test_leave.update_time IS '更新时间'; + + +-- for AT mode you must to init this sql for you business database. the seata server not need it. +CREATE TABLE IF NOT EXISTS public.undo_log +( + id SERIAL NOT NULL, + branch_id BIGINT NOT NULL, + xid VARCHAR(128) NOT NULL, + context VARCHAR(128) NOT NULL, + rollback_info BYTEA NOT NULL, + log_status INT NOT NULL, + log_created TIMESTAMP(0) NOT NULL, + log_modified TIMESTAMP(0) NOT NULL, + CONSTRAINT pk_undo_log PRIMARY KEY (id), + CONSTRAINT ux_undo_log UNIQUE (xid, branch_id) +); +CREATE INDEX ix_log_created ON undo_log(log_created); + +COMMENT ON TABLE public.undo_log IS 'AT transaction mode undo table'; +COMMENT ON COLUMN public.undo_log.branch_id IS 'branch transaction id'; +COMMENT ON COLUMN public.undo_log.xid IS 'global transaction id'; +COMMENT ON COLUMN public.undo_log.context IS 'undo_log context,such as serialization'; +COMMENT ON COLUMN public.undo_log.rollback_info IS 'rollback info'; +COMMENT ON COLUMN public.undo_log.log_status IS '0:normal status,1:defense status'; +COMMENT ON COLUMN public.undo_log.log_created IS 'create datetime'; +COMMENT ON COLUMN public.undo_log.log_modified IS 'modify datetime'; + +CREATE SEQUENCE IF NOT EXISTS undo_log_id_seq INCREMENT BY 1 MINVALUE 1 ; diff --git a/script/sql/ry-workflow.sql b/script/sql/ry-workflow.sql index 99640b39..542d6dee 100644 --- a/script/sql/ry-workflow.sql +++ b/script/sql/ry-workflow.sql @@ -201,3 +201,17 @@ create table test_leave update_time datetime null comment '更新时间', PRIMARY KEY (id) USING BTREE ) ENGINE = InnoDB COMMENT = '请假申请表'; + + +-- for AT mode you must to init this sql for you business database. the seata server not need it. +CREATE TABLE IF NOT EXISTS undo_log +( + branch_id BIGINT(20) NOT NULL COMMENT 'branch transaction id', + xid VARCHAR(100) NOT NULL COMMENT 'global transaction id', + context VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization', + rollback_info LONGBLOB NOT NULL COMMENT 'rollback info', + log_status INT(11) NOT NULL COMMENT '0:normal status,1:defense status', + log_created DATETIME(6) NOT NULL COMMENT 'create datetime', + log_modified DATETIME(6) NOT NULL COMMENT 'modify datetime', + UNIQUE KEY ux_undo_log (xid, branch_id) +) ENGINE = InnoDB COMMENT ='AT transaction mode undo table';