123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- CREATE DATABASE `seata-demo` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
- USE `seata-demo`;
- --==========================回滚日志表==========================
- -- the table to store seata xid data
- -- 0.7.0+ add context
- -- you must to init this sql for you business databese. the seata server not need it.
- -- 此脚本必须初始化在你当前的业务数据库中,用于AT 模式XID记录。与server端无关(注:业务数据库)
- -- 注意此处0.3.0+ 增加唯一索引 ux_undo_log
- drop table `undo_log`;
- CREATE TABLE `undo_log` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT,
- `branch_id` bigint(20) NOT NULL,
- `xid` varchar(100) NOT NULL,
- `context` varchar(128) NOT NULL,
- `rollback_info` longblob NOT NULL,
- `log_status` int(11) NOT NULL,
- `log_created` datetime NOT NULL,
- `log_modified` datetime NOT NULL,
- `ext` varchar(100) DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
- ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
- --==========================业务模拟表==========================
- DROP TABLE IF EXISTS `storage_tbl`;
- CREATE TABLE `storage_tbl` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `commodity_code` varchar(255) DEFAULT NULL,
- `count` int(11) DEFAULT 0,
- PRIMARY KEY (`id`),
- UNIQUE KEY (`commodity_code`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- DROP TABLE IF EXISTS `order_tbl`;
- CREATE TABLE `order_tbl` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` varchar(255) DEFAULT NULL,
- `commodity_code` varchar(255) DEFAULT NULL,
- `count` int(11) DEFAULT 0,
- `money` int(11) DEFAULT 0,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- DROP TABLE IF EXISTS `account_tbl`;
- CREATE TABLE `account_tbl` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` varchar(255) DEFAULT NULL,
- `money` int(11) DEFAULT 0,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- -- 初始化库存模拟数据
- INSERT INTO storage_tbl (id, commodity_code, count) VALUES (1, 'P001', 9999999);
- INSERT INTO account_tbl (id, user_id, money) VALUES ('1', 'U001', 10000);
|