seata-demo.sql 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. CREATE DATABASE `seata-demo` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  2. USE `seata-demo`;
  3. --==========================回滚日志表==========================
  4. -- the table to store seata xid data
  5. -- 0.7.0+ add context
  6. -- you must to init this sql for you business databese. the seata server not need it.
  7. -- 此脚本必须初始化在你当前的业务数据库中,用于AT 模式XID记录。与server端无关(注:业务数据库)
  8. -- 注意此处0.3.0+ 增加唯一索引 ux_undo_log
  9. drop table `undo_log`;
  10. CREATE TABLE `undo_log` (
  11. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  12. `branch_id` bigint(20) NOT NULL,
  13. `xid` varchar(100) NOT NULL,
  14. `context` varchar(128) NOT NULL,
  15. `rollback_info` longblob NOT NULL,
  16. `log_status` int(11) NOT NULL,
  17. `log_created` datetime NOT NULL,
  18. `log_modified` datetime NOT NULL,
  19. `ext` varchar(100) DEFAULT NULL,
  20. PRIMARY KEY (`id`),
  21. UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
  22. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
  23. --==========================业务模拟表==========================
  24. DROP TABLE IF EXISTS `storage_tbl`;
  25. CREATE TABLE `storage_tbl` (
  26. `id` int(11) NOT NULL AUTO_INCREMENT,
  27. `commodity_code` varchar(255) DEFAULT NULL,
  28. `count` int(11) DEFAULT 0,
  29. PRIMARY KEY (`id`),
  30. UNIQUE KEY (`commodity_code`)
  31. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  32. DROP TABLE IF EXISTS `order_tbl`;
  33. CREATE TABLE `order_tbl` (
  34. `id` int(11) NOT NULL AUTO_INCREMENT,
  35. `user_id` varchar(255) DEFAULT NULL,
  36. `commodity_code` varchar(255) DEFAULT NULL,
  37. `count` int(11) DEFAULT 0,
  38. `money` int(11) DEFAULT 0,
  39. PRIMARY KEY (`id`)
  40. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  41. DROP TABLE IF EXISTS `account_tbl`;
  42. CREATE TABLE `account_tbl` (
  43. `id` int(11) NOT NULL AUTO_INCREMENT,
  44. `user_id` varchar(255) DEFAULT NULL,
  45. `money` int(11) DEFAULT 0,
  46. PRIMARY KEY (`id`)
  47. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  48. -- 初始化库存模拟数据
  49. INSERT INTO storage_tbl (id, commodity_code, count) VALUES (1, 'P001', 9999999);
  50. INSERT INTO account_tbl (id, user_id, money) VALUES ('1', 'U001', 10000);