db2_init.sql 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. create table seata_state_machine_def
  2. (
  3. id varchar(32) not null,
  4. name varchar(128) not null,
  5. tenant_id varchar(32) not null,
  6. app_name varchar(32) not null,
  7. type varchar(20),
  8. comment_ varchar(255),
  9. ver varchar(16) not null,
  10. gmt_create timestamp(3) not null,
  11. status varchar(2) not null,
  12. content clob(65536) inline length 2048,
  13. recover_strategy varchar(16),
  14. primary key(id)
  15. );
  16. create table seata_state_machine_inst
  17. (
  18. id varchar(128) not null,
  19. machine_id varchar(32) not null,
  20. tenant_id varchar(32) not null,
  21. parent_id varchar(128),
  22. gmt_started timestamp(3) not null,
  23. business_key varchar(48),
  24. uni_business_key varchar(128) not null generated always as( --Unique index does not allow empty columns on DB2
  25. CASE
  26. WHEN "BUSINESS_KEY" IS NULL
  27. THEN "ID"
  28. ELSE "BUSINESS_KEY"
  29. END),
  30. start_params clob(65536) inline length 1024,
  31. gmt_end timestamp(3),
  32. excep blob(10240),
  33. end_params clob(65536) inline length 1024,
  34. status varchar(2),
  35. compensation_status varchar(2),
  36. is_running smallint,
  37. gmt_updated timestamp(3) not null,
  38. primary key(id)
  39. );
  40. create unique index state_machine_inst_unibuzkey on seata_state_machine_inst(uni_business_key, tenant_id);
  41. create table seata_state_inst
  42. (
  43. id varchar(48) not null,
  44. machine_inst_id varchar(128) not null,
  45. name varchar(128) not null,
  46. type varchar(20),
  47. service_name varchar(128),
  48. service_method varchar(128),
  49. service_type varchar(16),
  50. business_key varchar(48),
  51. state_id_compensated_for varchar(50),
  52. state_id_retried_for varchar(50),
  53. gmt_started timestamp(3) not null,
  54. is_for_update smallint,
  55. input_params clob(65536) inline length 1024,
  56. output_params clob(65536) inline length 1024,
  57. status varchar(2) not null,
  58. excep blob(10240),
  59. gmt_updated timestamp(3),
  60. gmt_end timestamp(3),
  61. primary key(id, machine_inst_id)
  62. );