You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

pgsql.sql 1.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. -- -------------------------------- The script used when storeMode is 'db' --------------------------------
  2. CREATE database seata;
  3. -- the table to store GlobalSession data
  4. CREATE TABLE IF NOT EXISTS global_table
  5. (
  6. addressing varchar(128) NOT NULL,
  7. xid varchar(128) NOT NULL,
  8. transaction_id bigint DEFAULT NULL,
  9. transaction_name varchar(128) DEFAULT NULL,
  10. timeout int DEFAULT NULL,
  11. begin_time bigint DEFAULT NULL,
  12. status int NOT NULL,
  13. active bool NOT NULL,
  14. gmt_create timestamp DEFAULT NULL,
  15. gmt_modified timestamp DEFAULT NULL,
  16. PRIMARY KEY (xid)
  17. );
  18. CREATE INDEX idx_gmt_modified_status ON global_table(gmt_modified, status);
  19. CREATE INDEX idx_transaction_id ON global_table(transaction_id);
  20. -- the table to store BranchSession data
  21. CREATE TABLE IF NOT EXISTS branch_table
  22. (
  23. addressing varchar(128) NOT NULL,
  24. xid varchar(128) NOT NULL,
  25. branch_id bigint NOT NULL,
  26. transaction_id bigint DEFAULT NULL,
  27. resource_id varchar(256) DEFAULT NULL,
  28. lock_key VARCHAR(1000),
  29. branch_type varchar(8) DEFAULT NULL,
  30. status int DEFAULT NULL,
  31. application_data varchar(2000) DEFAULT NULL,
  32. async_commit tinyint NOT NULL DEFAULT 1,
  33. gmt_create timestamp DEFAULT NULL,
  34. gmt_modified timestamp DEFAULT NULL,
  35. PRIMARY KEY (branch_id)
  36. );
  37. CREATE INDEX idx_xid ON branch_table(xid);
  38. -- the table to store lock data
  39. CREATE TABLE IF NOT EXISTS lock_table
  40. (
  41. row_key VARCHAR(256) NOT NULL,
  42. xid VARCHAR(128) NOT NULL,
  43. transaction_id BIGINT,
  44. branch_id BIGINT NOT NULL,
  45. resource_id VARCHAR(256),
  46. table_name VARCHAR(64),
  47. pk VARCHAR(36),
  48. gmt_create TIMESTAMP,
  49. gmt_modified TIMESTAMP,
  50. PRIMARY KEY (row_key)
  51. );
  52. CREATE INDEX idx_branch_id ON lock_table(branch_id);