From 236c8fb61cfee863bf436bb784a7b45cce65b4da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?v-=E6=9D=A8=E8=B6=85?= Date: Tue, 18 Jul 2023 16:30:03 +0800 Subject: [PATCH] update dtmsvr.storage.tdsql.sql --- sqls/dtmsvr.storage.tdsql.sql | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/sqls/dtmsvr.storage.tdsql.sql b/sqls/dtmsvr.storage.tdsql.sql index 1f04413..1c6f515 100644 --- a/sqls/dtmsvr.storage.tdsql.sql +++ b/sqls/dtmsvr.storage.tdsql.sql @@ -6,26 +6,26 @@ CREATE TABLE if not EXISTS dtm.trans_global ( `id` bigint(22) NOT NULL AUTO_INCREMENT, `gid` varchar(128) NOT NULL COMMENT 'global transaction id', `trans_type` varchar(45) not null COMMENT 'transaction type: saga | xa | tcc | msg', - `status` varchar(12) NOT NULL COMMENT 'tranaction status: prepared | submitted | aborting | finished | rollbacked', - `query_prepared` varchar(1024) NOT NULL COMMENT 'url to check for 2-phase message', + `status` varchar(12) NOT NULL COMMENT 'transaction status: prepared | submitted | aborting | succeed | failed', + `query_prepared` varchar(1024) NOT NULL COMMENT 'url to check for msg|workflow', `protocol` varchar(45) not null comment 'protocol: http | grpc | json-rpc', `create_time` datetime DEFAULT NULL, `update_time` datetime DEFAULT NULL, `finish_time` datetime DEFAULT NULL, `rollback_time` datetime DEFAULT NULL, - `options` varchar(1024) DEFAULT 'options for transaction like: TimeoutToFail, RequestTimeout', + `options` varchar(1024) DEFAULT '' COMMENT 'options for transaction like: TimeoutToFail, RequestTimeout', `custom_data` varchar(1024) DEFAULT '' COMMENT 'custom data for transaction', `next_cron_interval` int(11) default null comment 'next cron interval. for use of cron job', `next_cron_time` datetime default null comment 'next time to process this trans. for use of cron job', `owner` varchar(128) not null default '' comment 'who is locking this trans', - `ext_data` TEXT comment 'extended data for this trans', + `ext_data` TEXT comment 'extra data for this trans. currently used in workflow pattern', + `result` varchar(1024) DEFAULT '' COMMENT 'result for transaction', `rollback_reason` varchar(1024) DEFAULT '' COMMENT 'rollback reason for transaction', - PRIMARY KEY (`id`,`gid`), - UNIQUE KEY `id` (`id`,`gid`), + PRIMARY KEY (`id`), UNIQUE KEY `gid` (`gid`), key `owner`(`owner`), key `status_next_cron_time` (`status`, `next_cron_time`) comment 'cron job will use this index to query trans' -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 shardkey=gid; +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; drop table IF EXISTS dtm.trans_branch_op; CREATE TABLE IF NOT EXISTS dtm.trans_branch_op ( `id` bigint(22) NOT NULL AUTO_INCREMENT, @@ -40,7 +40,18 @@ CREATE TABLE IF NOT EXISTS dtm.trans_branch_op ( `rollback_time` datetime DEFAULT NULL, `create_time` datetime DEFAULT NULL, `update_time` datetime DEFAULT NULL, - PRIMARY KEY (`id`,`gid`), - UNIQUE KEY `id` (`id`,`gid`), + PRIMARY KEY (`id`), UNIQUE KEY `gid_uniq` (`gid`, `branch_id`, `op`) -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 shardkey=gid; +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; +drop table IF EXISTS dtm.kv; +CREATE TABLE IF NOT EXISTS dtm.kv ( + `id` bigint(22) NOT NULL AUTO_INCREMENT, + `cat` varchar(45) NOT NULL COMMENT 'the category of this data', + `k` varchar(128) NOT NULL, + `v` TEXT, + `version` bigint(22) default 1 COMMENT 'version of the value', + create_time datetime default NULL, + update_time datetime DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE key `uniq_k`(`cat`, `k`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;