ry_seata_20210128.sql 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. DROP DATABASE IF EXISTS `ry-seata`;
  2. CREATE DATABASE `ry-seata` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
  3. SET NAMES utf8mb4;
  4. SET FOREIGN_KEY_CHECKS = 0;
  5. USE `ry-seata`;
  6. -- -------------------------------- The script used when storeMode is 'db' --------------------------------
  7. -- the table to store GlobalSession data
  8. CREATE TABLE IF NOT EXISTS `global_table`
  9. (
  10. `xid` VARCHAR(128) NOT NULL,
  11. `transaction_id` BIGINT,
  12. `status` TINYINT NOT NULL,
  13. `application_id` VARCHAR(32),
  14. `transaction_service_group` VARCHAR(32),
  15. `transaction_name` VARCHAR(128),
  16. `timeout` INT,
  17. `begin_time` BIGINT,
  18. `application_data` VARCHAR(2000),
  19. `gmt_create` DATETIME,
  20. `gmt_modified` DATETIME,
  21. PRIMARY KEY (`xid`),
  22. KEY `idx_gmt_modified_status` (`gmt_modified`, `status`),
  23. KEY `idx_transaction_id` (`transaction_id`)
  24. ) ENGINE = InnoDB
  25. DEFAULT CHARSET = utf8mb4;
  26. -- the table to store BranchSession data
  27. CREATE TABLE IF NOT EXISTS `branch_table`
  28. (
  29. `branch_id` BIGINT NOT NULL,
  30. `xid` VARCHAR(128) NOT NULL,
  31. `transaction_id` BIGINT,
  32. `resource_group_id` VARCHAR(32),
  33. `resource_id` VARCHAR(256),
  34. `branch_type` VARCHAR(8),
  35. `status` TINYINT,
  36. `client_id` VARCHAR(64),
  37. `application_data` VARCHAR(2000),
  38. `gmt_create` DATETIME(6),
  39. `gmt_modified` DATETIME(6),
  40. PRIMARY KEY (`branch_id`),
  41. KEY `idx_xid` (`xid`)
  42. ) ENGINE = InnoDB
  43. DEFAULT CHARSET = utf8mb4;
  44. -- the table to store lock data
  45. CREATE TABLE IF NOT EXISTS `lock_table`
  46. (
  47. `row_key` VARCHAR(128) NOT NULL,
  48. `xid` VARCHAR(96),
  49. `transaction_id` BIGINT,
  50. `branch_id` BIGINT NOT NULL,
  51. `resource_id` VARCHAR(256),
  52. `table_name` VARCHAR(32),
  53. `pk` VARCHAR(36),
  54. `gmt_create` DATETIME,
  55. `gmt_modified` DATETIME,
  56. PRIMARY KEY (`row_key`),
  57. KEY `idx_branch_id` (`branch_id`)
  58. ) ENGINE = InnoDB
  59. DEFAULT CHARSET = utf8mb4;
  60. -- for AT mode you must to init this sql for you business database. the seata server not need it.
  61. CREATE TABLE IF NOT EXISTS `undo_log`
  62. (
  63. `branch_id` BIGINT(20) NOT NULL COMMENT 'branch transaction id',
  64. `xid` VARCHAR(100) NOT NULL COMMENT 'global transaction id',
  65. `context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
  66. `rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
  67. `log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
  68. `log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
  69. `log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
  70. UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
  71. ) ENGINE = InnoDB
  72. AUTO_INCREMENT = 1
  73. DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';