postgres_ry_job.sql 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. /*
  2. SnailJob Database Transfer Tool
  3. Source Server Type : MySQL
  4. Target Server Type : PostgreSQL
  5. Date: 2025-04-26 09:56:45
  6. */
  7. -- sj_namespace
  8. CREATE TABLE sj_namespace
  9. (
  10. id bigserial PRIMARY KEY,
  11. name varchar(64) NOT NULL,
  12. unique_id varchar(64) NOT NULL,
  13. description varchar(256) NOT NULL DEFAULT '',
  14. deleted smallint NOT NULL DEFAULT 0,
  15. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  16. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  17. );
  18. CREATE INDEX idx_sj_namespace_01 ON sj_namespace (name);
  19. COMMENT ON COLUMN sj_namespace.id IS '主键';
  20. COMMENT ON COLUMN sj_namespace.name IS '名称';
  21. COMMENT ON COLUMN sj_namespace.unique_id IS '唯一id';
  22. COMMENT ON COLUMN sj_namespace.description IS '描述';
  23. COMMENT ON COLUMN sj_namespace.deleted IS '逻辑删除 1、删除';
  24. COMMENT ON COLUMN sj_namespace.create_dt IS '创建时间';
  25. COMMENT ON COLUMN sj_namespace.update_dt IS '修改时间';
  26. COMMENT ON TABLE sj_namespace IS '命名空间';
  27. INSERT INTO sj_namespace VALUES (1, 'Development', 'dev', '', 0, now(), now());
  28. INSERT INTO sj_namespace VALUES (2, 'Production', 'prod', '', 0, now(), now());
  29. -- sj_group_config
  30. CREATE TABLE sj_group_config
  31. (
  32. id bigserial PRIMARY KEY,
  33. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  34. group_name varchar(64) NOT NULL DEFAULT '',
  35. description varchar(256) NOT NULL DEFAULT '',
  36. token varchar(64) NOT NULL DEFAULT 'SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT',
  37. group_status smallint NOT NULL DEFAULT 0,
  38. version int NOT NULL,
  39. group_partition int NOT NULL,
  40. id_generator_mode smallint NOT NULL DEFAULT 1,
  41. init_scene smallint NOT NULL DEFAULT 0,
  42. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  43. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  44. );
  45. CREATE UNIQUE INDEX uk_sj_group_config_01 ON sj_group_config (namespace_id, group_name);
  46. COMMENT ON COLUMN sj_group_config.id IS '主键';
  47. COMMENT ON COLUMN sj_group_config.namespace_id IS '命名空间id';
  48. COMMENT ON COLUMN sj_group_config.group_name IS '组名称';
  49. COMMENT ON COLUMN sj_group_config.description IS '组描述';
  50. COMMENT ON COLUMN sj_group_config.token IS 'token';
  51. COMMENT ON COLUMN sj_group_config.group_status IS '组状态 0、未启用 1、启用';
  52. COMMENT ON COLUMN sj_group_config.version IS '版本号';
  53. COMMENT ON COLUMN sj_group_config.group_partition IS '分区';
  54. COMMENT ON COLUMN sj_group_config.id_generator_mode IS '唯一id生成模式 默认号段模式';
  55. COMMENT ON COLUMN sj_group_config.init_scene IS '是否初始化场景 0:否 1:是';
  56. COMMENT ON COLUMN sj_group_config.create_dt IS '创建时间';
  57. COMMENT ON COLUMN sj_group_config.update_dt IS '修改时间';
  58. COMMENT ON TABLE sj_group_config IS '组配置';
  59. INSERT INTO sj_group_config VALUES (1, 'dev', 'ruoyi_group', '', 'SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT', 1, 1, 0, 1, 1, now(), now());
  60. INSERT INTO sj_group_config VALUES (2, 'prod', 'ruoyi_group', '', 'SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT', 1, 1, 0, 1, 1, now(), now());
  61. -- sj_notify_config
  62. CREATE TABLE sj_notify_config
  63. (
  64. id bigserial PRIMARY KEY,
  65. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  66. group_name varchar(64) NOT NULL,
  67. notify_name varchar(64) NOT NULL DEFAULT '',
  68. system_task_type smallint NOT NULL DEFAULT 3,
  69. notify_status smallint NOT NULL DEFAULT 0,
  70. recipient_ids varchar(128) NOT NULL,
  71. notify_threshold int NOT NULL DEFAULT 0,
  72. notify_scene smallint NOT NULL DEFAULT 0,
  73. rate_limiter_status smallint NOT NULL DEFAULT 0,
  74. rate_limiter_threshold int NOT NULL DEFAULT 0,
  75. description varchar(256) NOT NULL DEFAULT '',
  76. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  77. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  78. );
  79. CREATE INDEX idx_sj_notify_config_01 ON sj_notify_config (namespace_id, group_name);
  80. COMMENT ON COLUMN sj_notify_config.id IS '主键';
  81. COMMENT ON COLUMN sj_notify_config.namespace_id IS '命名空间id';
  82. COMMENT ON COLUMN sj_notify_config.group_name IS '组名称';
  83. COMMENT ON COLUMN sj_notify_config.notify_name IS '通知名称';
  84. COMMENT ON COLUMN sj_notify_config.system_task_type IS '任务类型 1. 重试任务 2. 重试回调 3、JOB任务 4、WORKFLOW任务';
  85. COMMENT ON COLUMN sj_notify_config.notify_status IS '通知状态 0、未启用 1、启用';
  86. COMMENT ON COLUMN sj_notify_config.recipient_ids IS '接收人id列表';
  87. COMMENT ON COLUMN sj_notify_config.notify_threshold IS '通知阈值';
  88. COMMENT ON COLUMN sj_notify_config.notify_scene IS '通知场景';
  89. COMMENT ON COLUMN sj_notify_config.rate_limiter_status IS '限流状态 0、未启用 1、启用';
  90. COMMENT ON COLUMN sj_notify_config.rate_limiter_threshold IS '每秒限流阈值';
  91. COMMENT ON COLUMN sj_notify_config.description IS '描述';
  92. COMMENT ON COLUMN sj_notify_config.create_dt IS '创建时间';
  93. COMMENT ON COLUMN sj_notify_config.update_dt IS '修改时间';
  94. COMMENT ON TABLE sj_notify_config IS '通知配置';
  95. -- sj_notify_recipient
  96. CREATE TABLE sj_notify_recipient
  97. (
  98. id bigserial PRIMARY KEY,
  99. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  100. recipient_name varchar(64) NOT NULL,
  101. notify_type smallint NOT NULL DEFAULT 0,
  102. notify_attribute varchar(512) NOT NULL,
  103. description varchar(256) NOT NULL DEFAULT '',
  104. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  105. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  106. );
  107. CREATE INDEX idx_sj_notify_recipient_01 ON sj_notify_recipient (namespace_id);
  108. COMMENT ON COLUMN sj_notify_recipient.id IS '主键';
  109. COMMENT ON COLUMN sj_notify_recipient.namespace_id IS '命名空间id';
  110. COMMENT ON COLUMN sj_notify_recipient.recipient_name IS '接收人名称';
  111. COMMENT ON COLUMN sj_notify_recipient.notify_type IS '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书 5 webhook';
  112. COMMENT ON COLUMN sj_notify_recipient.notify_attribute IS '配置属性';
  113. COMMENT ON COLUMN sj_notify_recipient.description IS '描述';
  114. COMMENT ON COLUMN sj_notify_recipient.create_dt IS '创建时间';
  115. COMMENT ON COLUMN sj_notify_recipient.update_dt IS '修改时间';
  116. COMMENT ON TABLE sj_notify_recipient IS '告警通知接收人';
  117. -- sj_retry_dead_letter
  118. CREATE TABLE sj_retry_dead_letter
  119. (
  120. id bigserial PRIMARY KEY,
  121. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  122. group_name varchar(64) NOT NULL,
  123. group_id bigint NOT NULL,
  124. scene_name varchar(64) NOT NULL,
  125. scene_id bigint NOT NULL,
  126. idempotent_id varchar(64) NOT NULL,
  127. biz_no varchar(64) NOT NULL DEFAULT '',
  128. executor_name varchar(512) NOT NULL DEFAULT '',
  129. args_str text NOT NULL,
  130. ext_attrs text NOT NULL,
  131. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  132. );
  133. CREATE INDEX idx_sj_retry_dead_letter_01 ON sj_retry_dead_letter (namespace_id, group_name, scene_name);
  134. CREATE INDEX idx_sj_retry_dead_letter_02 ON sj_retry_dead_letter (idempotent_id);
  135. CREATE INDEX idx_sj_retry_dead_letter_03 ON sj_retry_dead_letter (biz_no);
  136. CREATE INDEX idx_sj_retry_dead_letter_04 ON sj_retry_dead_letter (create_dt);
  137. COMMENT ON COLUMN sj_retry_dead_letter.id IS '主键';
  138. COMMENT ON COLUMN sj_retry_dead_letter.namespace_id IS '命名空间id';
  139. COMMENT ON COLUMN sj_retry_dead_letter.group_name IS '组名称';
  140. COMMENT ON COLUMN sj_retry_dead_letter.group_id IS '组Id';
  141. COMMENT ON COLUMN sj_retry_dead_letter.scene_name IS '场景名称';
  142. COMMENT ON COLUMN sj_retry_dead_letter.scene_id IS '场景ID';
  143. COMMENT ON COLUMN sj_retry_dead_letter.idempotent_id IS '幂等id';
  144. COMMENT ON COLUMN sj_retry_dead_letter.biz_no IS '业务编号';
  145. COMMENT ON COLUMN sj_retry_dead_letter.executor_name IS '执行器名称';
  146. COMMENT ON COLUMN sj_retry_dead_letter.args_str IS '执行方法参数';
  147. COMMENT ON COLUMN sj_retry_dead_letter.ext_attrs IS '扩展字段';
  148. COMMENT ON COLUMN sj_retry_dead_letter.create_dt IS '创建时间';
  149. COMMENT ON TABLE sj_retry_dead_letter IS '死信队列表';
  150. -- sj_retry
  151. CREATE TABLE sj_retry
  152. (
  153. id bigserial PRIMARY KEY,
  154. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  155. group_name varchar(64) NOT NULL,
  156. group_id bigint NOT NULL,
  157. scene_name varchar(64) NOT NULL,
  158. scene_id bigint NOT NULL,
  159. idempotent_id varchar(64) NOT NULL,
  160. biz_no varchar(64) NOT NULL DEFAULT '',
  161. executor_name varchar(512) NOT NULL DEFAULT '',
  162. args_str text NOT NULL,
  163. ext_attrs text NOT NULL,
  164. next_trigger_at bigint NOT NULL,
  165. retry_count int NOT NULL DEFAULT 0,
  166. retry_status smallint NOT NULL DEFAULT 0,
  167. task_type smallint NOT NULL DEFAULT 1,
  168. bucket_index int NOT NULL DEFAULT 0,
  169. parent_id bigint NOT NULL DEFAULT 0,
  170. deleted bigint NOT NULL DEFAULT 0,
  171. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  172. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  173. );
  174. CREATE UNIQUE INDEX uk_sj_retry_01 ON sj_retry (scene_id, task_type, idempotent_id, deleted);
  175. CREATE INDEX idx_sj_retry_01 ON sj_retry (biz_no);
  176. CREATE INDEX idx_sj_retry_02 ON sj_retry (retry_status, bucket_index);
  177. CREATE INDEX idx_sj_retry_03 ON sj_retry (parent_id);
  178. CREATE INDEX idx_sj_retry_04 ON sj_retry (create_dt);
  179. CREATE INDEX idx_sj_retry_05 ON sj_retry (idempotent_id);
  180. COMMENT ON COLUMN sj_retry.id IS '主键';
  181. COMMENT ON COLUMN sj_retry.namespace_id IS '命名空间id';
  182. COMMENT ON COLUMN sj_retry.group_name IS '组名称';
  183. COMMENT ON COLUMN sj_retry.group_id IS '组Id';
  184. COMMENT ON COLUMN sj_retry.scene_name IS '场景名称';
  185. COMMENT ON COLUMN sj_retry.scene_id IS '场景ID';
  186. COMMENT ON COLUMN sj_retry.idempotent_id IS '幂等id';
  187. COMMENT ON COLUMN sj_retry.biz_no IS '业务编号';
  188. COMMENT ON COLUMN sj_retry.executor_name IS '执行器名称';
  189. COMMENT ON COLUMN sj_retry.args_str IS '执行方法参数';
  190. COMMENT ON COLUMN sj_retry.ext_attrs IS '扩展字段';
  191. COMMENT ON COLUMN sj_retry.next_trigger_at IS '下次触发时间';
  192. COMMENT ON COLUMN sj_retry.retry_count IS '重试次数';
  193. COMMENT ON COLUMN sj_retry.retry_status IS '重试状态 0、重试中 1、成功 2、最大重试次数';
  194. COMMENT ON COLUMN sj_retry.task_type IS '任务类型 1、重试数据 2、回调数据';
  195. COMMENT ON COLUMN sj_retry.bucket_index IS 'bucket';
  196. COMMENT ON COLUMN sj_retry.parent_id IS '父节点id';
  197. COMMENT ON COLUMN sj_retry.deleted IS '逻辑删除';
  198. COMMENT ON COLUMN sj_retry.create_dt IS '创建时间';
  199. COMMENT ON COLUMN sj_retry.update_dt IS '修改时间';
  200. COMMENT ON TABLE sj_retry IS '重试信息表';
  201. -- sj_retry_task
  202. CREATE TABLE sj_retry_task
  203. (
  204. id bigserial PRIMARY KEY,
  205. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  206. group_name varchar(64) NOT NULL,
  207. scene_name varchar(64) NOT NULL,
  208. retry_id bigint NOT NULL,
  209. ext_attrs text NOT NULL,
  210. task_status smallint NOT NULL DEFAULT 1,
  211. task_type smallint NOT NULL DEFAULT 1,
  212. operation_reason smallint NOT NULL DEFAULT 0,
  213. client_info varchar(128) NULL DEFAULT NULL,
  214. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  215. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  216. );
  217. CREATE INDEX idx_sj_retry_task_01 ON sj_retry_task (namespace_id, group_name, scene_name);
  218. CREATE INDEX idx_sj_retry_task_02 ON sj_retry_task (task_status);
  219. CREATE INDEX idx_sj_retry_task_03 ON sj_retry_task (create_dt);
  220. CREATE INDEX idx_sj_retry_task_04 ON sj_retry_task (retry_id);
  221. COMMENT ON COLUMN sj_retry_task.id IS '主键';
  222. COMMENT ON COLUMN sj_retry_task.namespace_id IS '命名空间id';
  223. COMMENT ON COLUMN sj_retry_task.group_name IS '组名称';
  224. COMMENT ON COLUMN sj_retry_task.scene_name IS '场景名称';
  225. COMMENT ON COLUMN sj_retry_task.retry_id IS '重试信息Id';
  226. COMMENT ON COLUMN sj_retry_task.ext_attrs IS '扩展字段';
  227. COMMENT ON COLUMN sj_retry_task.task_status IS '重试状态';
  228. COMMENT ON COLUMN sj_retry_task.task_type IS '任务类型 1、重试数据 2、回调数据';
  229. COMMENT ON COLUMN sj_retry_task.operation_reason IS '操作原因';
  230. COMMENT ON COLUMN sj_retry_task.client_info IS '客户端地址 clientId#ip:port';
  231. COMMENT ON COLUMN sj_retry_task.create_dt IS '创建时间';
  232. COMMENT ON COLUMN sj_retry_task.update_dt IS '修改时间';
  233. COMMENT ON TABLE sj_retry_task IS '重试任务表';
  234. -- sj_retry_task_log_message
  235. CREATE TABLE sj_retry_task_log_message
  236. (
  237. id bigserial PRIMARY KEY,
  238. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  239. group_name varchar(64) NOT NULL,
  240. retry_id bigint NOT NULL,
  241. retry_task_id bigint NOT NULL,
  242. message text NOT NULL,
  243. log_num int NOT NULL DEFAULT 1,
  244. real_time bigint NOT NULL DEFAULT 0,
  245. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  246. );
  247. CREATE INDEX idx_sj_retry_task_log_message_01 ON sj_retry_task_log_message (namespace_id, group_name, retry_task_id);
  248. CREATE INDEX idx_sj_retry_task_log_message_02 ON sj_retry_task_log_message (create_dt);
  249. COMMENT ON COLUMN sj_retry_task_log_message.id IS '主键';
  250. COMMENT ON COLUMN sj_retry_task_log_message.namespace_id IS '命名空间id';
  251. COMMENT ON COLUMN sj_retry_task_log_message.group_name IS '组名称';
  252. COMMENT ON COLUMN sj_retry_task_log_message.retry_id IS '重试信息Id';
  253. COMMENT ON COLUMN sj_retry_task_log_message.retry_task_id IS '重试任务Id';
  254. COMMENT ON COLUMN sj_retry_task_log_message.message IS '异常信息';
  255. COMMENT ON COLUMN sj_retry_task_log_message.log_num IS '日志数量';
  256. COMMENT ON COLUMN sj_retry_task_log_message.real_time IS '上报时间';
  257. COMMENT ON COLUMN sj_retry_task_log_message.create_dt IS '创建时间';
  258. COMMENT ON TABLE sj_retry_task_log_message IS '任务调度日志信息记录表';
  259. -- sj_retry_scene_config
  260. CREATE TABLE sj_retry_scene_config
  261. (
  262. id bigserial PRIMARY KEY,
  263. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  264. scene_name varchar(64) NOT NULL,
  265. group_name varchar(64) NOT NULL,
  266. scene_status smallint NOT NULL DEFAULT 0,
  267. max_retry_count int NOT NULL DEFAULT 5,
  268. back_off smallint NOT NULL DEFAULT 1,
  269. trigger_interval varchar(16) NOT NULL DEFAULT '',
  270. notify_ids varchar(128) NOT NULL DEFAULT '',
  271. deadline_request bigint NOT NULL DEFAULT 60000,
  272. executor_timeout int NOT NULL DEFAULT 5,
  273. route_key smallint NOT NULL DEFAULT 4,
  274. block_strategy smallint NOT NULL DEFAULT 1,
  275. cb_status smallint NOT NULL DEFAULT 0,
  276. cb_trigger_type smallint NOT NULL DEFAULT 1,
  277. cb_max_count int NOT NULL DEFAULT 16,
  278. cb_trigger_interval varchar(16) NOT NULL DEFAULT '',
  279. description varchar(256) NOT NULL DEFAULT '',
  280. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  281. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  282. );
  283. CREATE UNIQUE INDEX uk_sj_retry_scene_config_01 ON sj_retry_scene_config (namespace_id, group_name, scene_name);
  284. COMMENT ON COLUMN sj_retry_scene_config.id IS '主键';
  285. COMMENT ON COLUMN sj_retry_scene_config.namespace_id IS '命名空间id';
  286. COMMENT ON COLUMN sj_retry_scene_config.scene_name IS '场景名称';
  287. COMMENT ON COLUMN sj_retry_scene_config.group_name IS '组名称';
  288. COMMENT ON COLUMN sj_retry_scene_config.scene_status IS '组状态 0、未启用 1、启用';
  289. COMMENT ON COLUMN sj_retry_scene_config.max_retry_count IS '最大重试次数';
  290. COMMENT ON COLUMN sj_retry_scene_config.back_off IS '1、默认等级 2、固定间隔时间 3、CRON 表达式';
  291. COMMENT ON COLUMN sj_retry_scene_config.trigger_interval IS '间隔时长';
  292. COMMENT ON COLUMN sj_retry_scene_config.notify_ids IS '通知告警场景配置id列表';
  293. COMMENT ON COLUMN sj_retry_scene_config.deadline_request IS 'Deadline Request 调用链超时 单位毫秒';
  294. COMMENT ON COLUMN sj_retry_scene_config.executor_timeout IS '任务执行超时时间,单位秒';
  295. COMMENT ON COLUMN sj_retry_scene_config.route_key IS '路由策略';
  296. COMMENT ON COLUMN sj_retry_scene_config.block_strategy IS '阻塞策略 1、丢弃 2、覆盖 3、并行';
  297. COMMENT ON COLUMN sj_retry_scene_config.cb_status IS '回调状态 0、不开启 1、开启';
  298. COMMENT ON COLUMN sj_retry_scene_config.cb_trigger_type IS '1、默认等级 2、固定间隔时间 3、CRON 表达式';
  299. COMMENT ON COLUMN sj_retry_scene_config.cb_max_count IS '回调的最大执行次数';
  300. COMMENT ON COLUMN sj_retry_scene_config.cb_trigger_interval IS '回调的最大执行次数';
  301. COMMENT ON COLUMN sj_retry_scene_config.description IS '描述';
  302. COMMENT ON COLUMN sj_retry_scene_config.create_dt IS '创建时间';
  303. COMMENT ON COLUMN sj_retry_scene_config.update_dt IS '修改时间';
  304. COMMENT ON TABLE sj_retry_scene_config IS '场景配置';
  305. -- sj_server_node
  306. CREATE TABLE sj_server_node
  307. (
  308. id bigserial PRIMARY KEY,
  309. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  310. group_name varchar(64) NOT NULL,
  311. host_id varchar(64) NOT NULL,
  312. host_ip varchar(64) NOT NULL,
  313. host_port int NOT NULL,
  314. expire_at timestamp NOT NULL,
  315. node_type smallint NOT NULL,
  316. ext_attrs varchar(256) NULL DEFAULT '',
  317. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  318. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  319. );
  320. CREATE UNIQUE INDEX uk_sj_server_node_01 ON sj_server_node (host_id, host_ip);
  321. CREATE INDEX idx_sj_server_node_01 ON sj_server_node (namespace_id, group_name);
  322. CREATE INDEX idx_sj_server_node_02 ON sj_server_node (expire_at, node_type);
  323. COMMENT ON COLUMN sj_server_node.id IS '主键';
  324. COMMENT ON COLUMN sj_server_node.namespace_id IS '命名空间id';
  325. COMMENT ON COLUMN sj_server_node.group_name IS '组名称';
  326. COMMENT ON COLUMN sj_server_node.host_id IS '主机id';
  327. COMMENT ON COLUMN sj_server_node.host_ip IS '机器ip';
  328. COMMENT ON COLUMN sj_server_node.host_port IS '机器端口';
  329. COMMENT ON COLUMN sj_server_node.expire_at IS '过期时间';
  330. COMMENT ON COLUMN sj_server_node.node_type IS '节点类型 1、客户端 2、是服务端';
  331. COMMENT ON COLUMN sj_server_node.ext_attrs IS '扩展字段';
  332. COMMENT ON COLUMN sj_server_node.create_dt IS '创建时间';
  333. COMMENT ON COLUMN sj_server_node.update_dt IS '修改时间';
  334. COMMENT ON TABLE sj_server_node IS '服务器节点';
  335. -- sj_distributed_lock
  336. CREATE TABLE sj_distributed_lock
  337. (
  338. name varchar(64) NOT NULL,
  339. lock_until timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
  340. locked_at timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
  341. locked_by varchar(255) NOT NULL,
  342. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  343. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  344. );
  345. COMMENT ON COLUMN sj_distributed_lock.name IS '锁名称';
  346. COMMENT ON COLUMN sj_distributed_lock.lock_until IS '锁定时长';
  347. COMMENT ON COLUMN sj_distributed_lock.locked_at IS '锁定时间';
  348. COMMENT ON COLUMN sj_distributed_lock.locked_by IS '锁定者';
  349. COMMENT ON COLUMN sj_distributed_lock.create_dt IS '创建时间';
  350. COMMENT ON COLUMN sj_distributed_lock.update_dt IS '修改时间';
  351. COMMENT ON TABLE sj_distributed_lock IS '锁定表';
  352. -- sj_system_user
  353. CREATE TABLE sj_system_user
  354. (
  355. id bigserial PRIMARY KEY,
  356. username varchar(64) NOT NULL,
  357. password varchar(128) NOT NULL,
  358. role smallint NOT NULL DEFAULT 0,
  359. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  360. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  361. );
  362. COMMENT ON COLUMN sj_system_user.id IS '主键';
  363. COMMENT ON COLUMN sj_system_user.username IS '账号';
  364. COMMENT ON COLUMN sj_system_user.password IS '密码';
  365. COMMENT ON COLUMN sj_system_user.role IS '角色:1-普通用户、2-管理员';
  366. COMMENT ON COLUMN sj_system_user.create_dt IS '创建时间';
  367. COMMENT ON COLUMN sj_system_user.update_dt IS '修改时间';
  368. COMMENT ON TABLE sj_system_user IS '系统用户表';
  369. -- pwd: admin
  370. INSERT INTO sj_system_user VALUES (1, 'admin', '465c194afb65670f38322df087f0a9bb225cc257e43eb4ac5a0c98ef5b3173ac', 2, now(), now());
  371. -- sj_system_user_permission
  372. CREATE TABLE sj_system_user_permission
  373. (
  374. id bigserial PRIMARY KEY,
  375. group_name varchar(64) NOT NULL,
  376. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  377. system_user_id bigint NOT NULL,
  378. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  379. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  380. );
  381. CREATE UNIQUE INDEX uk_sj_system_user_permission_01 ON sj_system_user_permission (namespace_id, group_name, system_user_id);
  382. COMMENT ON COLUMN sj_system_user_permission.id IS '主键';
  383. COMMENT ON COLUMN sj_system_user_permission.group_name IS '组名称';
  384. COMMENT ON COLUMN sj_system_user_permission.namespace_id IS '命名空间id';
  385. COMMENT ON COLUMN sj_system_user_permission.system_user_id IS '系统用户id';
  386. COMMENT ON COLUMN sj_system_user_permission.create_dt IS '创建时间';
  387. COMMENT ON COLUMN sj_system_user_permission.update_dt IS '修改时间';
  388. COMMENT ON TABLE sj_system_user_permission IS '系统用户权限表';
  389. -- sj_sequence_alloc
  390. CREATE TABLE sj_sequence_alloc
  391. (
  392. id bigserial PRIMARY KEY,
  393. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  394. group_name varchar(64) NOT NULL DEFAULT '',
  395. max_id bigint NOT NULL DEFAULT 1,
  396. step int NOT NULL DEFAULT 100,
  397. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  398. );
  399. CREATE UNIQUE INDEX uk_sj_sequence_alloc_01 ON sj_sequence_alloc (namespace_id, group_name);
  400. COMMENT ON COLUMN sj_sequence_alloc.id IS '主键';
  401. COMMENT ON COLUMN sj_sequence_alloc.namespace_id IS '命名空间id';
  402. COMMENT ON COLUMN sj_sequence_alloc.group_name IS '组名称';
  403. COMMENT ON COLUMN sj_sequence_alloc.max_id IS '最大id';
  404. COMMENT ON COLUMN sj_sequence_alloc.step IS '步长';
  405. COMMENT ON COLUMN sj_sequence_alloc.update_dt IS '更新时间';
  406. COMMENT ON TABLE sj_sequence_alloc IS '号段模式序号ID分配表';
  407. -- sj_job
  408. CREATE TABLE sj_job
  409. (
  410. id bigserial PRIMARY KEY,
  411. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  412. group_name varchar(64) NOT NULL,
  413. job_name varchar(64) NOT NULL,
  414. args_str text NULL DEFAULT NULL,
  415. args_type smallint NOT NULL DEFAULT 1,
  416. next_trigger_at bigint NOT NULL,
  417. job_status smallint NOT NULL DEFAULT 1,
  418. task_type smallint NOT NULL DEFAULT 1,
  419. route_key smallint NOT NULL DEFAULT 4,
  420. executor_type smallint NOT NULL DEFAULT 1,
  421. executor_info varchar(255) NULL DEFAULT NULL,
  422. trigger_type smallint NOT NULL,
  423. trigger_interval varchar(255) NOT NULL,
  424. block_strategy smallint NOT NULL DEFAULT 1,
  425. executor_timeout int NOT NULL DEFAULT 0,
  426. max_retry_times int NOT NULL DEFAULT 0,
  427. parallel_num int NOT NULL DEFAULT 1,
  428. retry_interval int NOT NULL DEFAULT 0,
  429. bucket_index int NOT NULL DEFAULT 0,
  430. resident smallint NOT NULL DEFAULT 0,
  431. notify_ids varchar(128) NOT NULL DEFAULT '',
  432. owner_id bigint NULL,
  433. description varchar(256) NOT NULL DEFAULT '',
  434. ext_attrs varchar(256) NULL DEFAULT '',
  435. deleted smallint NOT NULL DEFAULT 0,
  436. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  437. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  438. );
  439. CREATE INDEX idx_sj_job_01 ON sj_job (namespace_id, group_name);
  440. CREATE INDEX idx_sj_job_02 ON sj_job (job_status, bucket_index);
  441. CREATE INDEX idx_sj_job_03 ON sj_job (create_dt);
  442. COMMENT ON COLUMN sj_job.id IS '主键';
  443. COMMENT ON COLUMN sj_job.namespace_id IS '命名空间id';
  444. COMMENT ON COLUMN sj_job.group_name IS '组名称';
  445. COMMENT ON COLUMN sj_job.job_name IS '名称';
  446. COMMENT ON COLUMN sj_job.args_str IS '执行方法参数';
  447. COMMENT ON COLUMN sj_job.args_type IS '参数类型 ';
  448. COMMENT ON COLUMN sj_job.next_trigger_at IS '下次触发时间';
  449. COMMENT ON COLUMN sj_job.job_status IS '任务状态 0、关闭、1、开启';
  450. COMMENT ON COLUMN sj_job.task_type IS '任务类型 1、集群 2、广播 3、切片';
  451. COMMENT ON COLUMN sj_job.route_key IS '路由策略';
  452. COMMENT ON COLUMN sj_job.executor_type IS '执行器类型';
  453. COMMENT ON COLUMN sj_job.executor_info IS '执行器名称';
  454. COMMENT ON COLUMN sj_job.trigger_type IS '触发类型 1.CRON 表达式 2. 固定时间';
  455. COMMENT ON COLUMN sj_job.trigger_interval IS '间隔时长';
  456. COMMENT ON COLUMN sj_job.block_strategy IS '阻塞策略 1、丢弃 2、覆盖 3、并行 4、恢复';
  457. COMMENT ON COLUMN sj_job.executor_timeout IS '任务执行超时时间,单位秒';
  458. COMMENT ON COLUMN sj_job.max_retry_times IS '最大重试次数';
  459. COMMENT ON COLUMN sj_job.parallel_num IS '并行数';
  460. COMMENT ON COLUMN sj_job.retry_interval IS '重试间隔 ( s)';
  461. COMMENT ON COLUMN sj_job.bucket_index IS 'bucket';
  462. COMMENT ON COLUMN sj_job.resident IS '是否是常驻任务';
  463. COMMENT ON COLUMN sj_job.notify_ids IS '通知告警场景配置id列表';
  464. COMMENT ON COLUMN sj_job.owner_id IS '负责人id';
  465. COMMENT ON COLUMN sj_job.description IS '描述';
  466. COMMENT ON COLUMN sj_job.ext_attrs IS '扩展字段';
  467. COMMENT ON COLUMN sj_job.deleted IS '逻辑删除 1、删除';
  468. COMMENT ON COLUMN sj_job.create_dt IS '创建时间';
  469. COMMENT ON COLUMN sj_job.update_dt IS '修改时间';
  470. COMMENT ON TABLE sj_job IS '任务信息';
  471. INSERT INTO sj_job VALUES (1, 'dev', 'ruoyi_group', 'demo-job', null, 1, 1710344035622, 1, 1, 4, 1, 'testJobExecutor', 2, '60', 1, 60, 3, 1, 1, 116, 0, '', 1, '', '', 0, now(), now());
  472. -- sj_job_log_message
  473. CREATE TABLE sj_job_log_message
  474. (
  475. id bigserial PRIMARY KEY,
  476. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  477. group_name varchar(64) NOT NULL,
  478. job_id bigint NOT NULL,
  479. task_batch_id bigint NOT NULL,
  480. task_id bigint NOT NULL,
  481. message text NOT NULL,
  482. log_num int NOT NULL DEFAULT 1,
  483. real_time bigint NOT NULL DEFAULT 0,
  484. ext_attrs varchar(256) NULL DEFAULT '',
  485. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  486. );
  487. CREATE INDEX idx_sj_job_log_message_01 ON sj_job_log_message (task_batch_id, task_id);
  488. CREATE INDEX idx_sj_job_log_message_02 ON sj_job_log_message (create_dt);
  489. CREATE INDEX idx_sj_job_log_message_03 ON sj_job_log_message (namespace_id, group_name);
  490. COMMENT ON COLUMN sj_job_log_message.id IS '主键';
  491. COMMENT ON COLUMN sj_job_log_message.namespace_id IS '命名空间id';
  492. COMMENT ON COLUMN sj_job_log_message.group_name IS '组名称';
  493. COMMENT ON COLUMN sj_job_log_message.job_id IS '任务信息id';
  494. COMMENT ON COLUMN sj_job_log_message.task_batch_id IS '任务批次id';
  495. COMMENT ON COLUMN sj_job_log_message.task_id IS '调度任务id';
  496. COMMENT ON COLUMN sj_job_log_message.message IS '调度信息';
  497. COMMENT ON COLUMN sj_job_log_message.log_num IS '日志数量';
  498. COMMENT ON COLUMN sj_job_log_message.real_time IS '上报时间';
  499. COMMENT ON COLUMN sj_job_log_message.ext_attrs IS '扩展字段';
  500. COMMENT ON COLUMN sj_job_log_message.create_dt IS '创建时间';
  501. COMMENT ON TABLE sj_job_log_message IS '调度日志';
  502. -- sj_job_task
  503. CREATE TABLE sj_job_task
  504. (
  505. id bigserial PRIMARY KEY,
  506. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  507. group_name varchar(64) NOT NULL,
  508. job_id bigint NOT NULL,
  509. task_batch_id bigint NOT NULL,
  510. parent_id bigint NOT NULL DEFAULT 0,
  511. task_status smallint NOT NULL DEFAULT 0,
  512. retry_count int NOT NULL DEFAULT 0,
  513. mr_stage smallint NULL DEFAULT NULL,
  514. leaf smallint NOT NULL DEFAULT '1',
  515. task_name varchar(255) NOT NULL DEFAULT '',
  516. client_info varchar(128) NULL DEFAULT NULL,
  517. wf_context text NULL DEFAULT NULL,
  518. result_message text NOT NULL,
  519. args_str text NULL DEFAULT NULL,
  520. args_type smallint NOT NULL DEFAULT 1,
  521. ext_attrs varchar(256) NULL DEFAULT '',
  522. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  523. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  524. );
  525. CREATE INDEX idx_sj_job_task_01 ON sj_job_task (task_batch_id, task_status);
  526. CREATE INDEX idx_sj_job_task_02 ON sj_job_task (create_dt);
  527. CREATE INDEX idx_sj_job_task_03 ON sj_job_task (namespace_id, group_name);
  528. COMMENT ON COLUMN sj_job_task.id IS '主键';
  529. COMMENT ON COLUMN sj_job_task.namespace_id IS '命名空间id';
  530. COMMENT ON COLUMN sj_job_task.group_name IS '组名称';
  531. COMMENT ON COLUMN sj_job_task.job_id IS '任务信息id';
  532. COMMENT ON COLUMN sj_job_task.task_batch_id IS '调度任务id';
  533. COMMENT ON COLUMN sj_job_task.parent_id IS '父执行器id';
  534. COMMENT ON COLUMN sj_job_task.task_status IS '执行的状态 0、失败 1、成功';
  535. COMMENT ON COLUMN sj_job_task.retry_count IS '重试次数';
  536. COMMENT ON COLUMN sj_job_task.mr_stage IS '动态分片所处阶段 1:map 2:reduce 3:mergeReduce';
  537. COMMENT ON COLUMN sj_job_task.leaf IS '叶子节点';
  538. COMMENT ON COLUMN sj_job_task.task_name IS '任务名称';
  539. COMMENT ON COLUMN sj_job_task.client_info IS '客户端地址 clientId#ip:port';
  540. COMMENT ON COLUMN sj_job_task.wf_context IS '工作流全局上下文';
  541. COMMENT ON COLUMN sj_job_task.result_message IS '执行结果';
  542. COMMENT ON COLUMN sj_job_task.args_str IS '执行方法参数';
  543. COMMENT ON COLUMN sj_job_task.args_type IS '参数类型 ';
  544. COMMENT ON COLUMN sj_job_task.ext_attrs IS '扩展字段';
  545. COMMENT ON COLUMN sj_job_task.create_dt IS '创建时间';
  546. COMMENT ON COLUMN sj_job_task.update_dt IS '修改时间';
  547. COMMENT ON TABLE sj_job_task IS '任务实例';
  548. -- sj_job_task_batch
  549. CREATE TABLE sj_job_task_batch
  550. (
  551. id bigserial PRIMARY KEY,
  552. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  553. group_name varchar(64) NOT NULL,
  554. job_id bigint NOT NULL,
  555. workflow_node_id bigint NOT NULL DEFAULT 0,
  556. parent_workflow_node_id bigint NOT NULL DEFAULT 0,
  557. workflow_task_batch_id bigint NOT NULL DEFAULT 0,
  558. task_batch_status smallint NOT NULL DEFAULT 0,
  559. operation_reason smallint NOT NULL DEFAULT 0,
  560. execution_at bigint NOT NULL DEFAULT 0,
  561. system_task_type smallint NOT NULL DEFAULT 3,
  562. parent_id varchar(64) NOT NULL DEFAULT '',
  563. ext_attrs varchar(256) NULL DEFAULT '',
  564. deleted smallint NOT NULL DEFAULT 0,
  565. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  566. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  567. );
  568. CREATE INDEX idx_sj_job_task_batch_01 ON sj_job_task_batch (job_id, task_batch_status);
  569. CREATE INDEX idx_sj_job_task_batch_02 ON sj_job_task_batch (create_dt);
  570. CREATE INDEX idx_sj_job_task_batch_03 ON sj_job_task_batch (namespace_id, group_name);
  571. CREATE INDEX idx_sj_job_task_batch_04 ON sj_job_task_batch (workflow_task_batch_id, workflow_node_id);
  572. COMMENT ON COLUMN sj_job_task_batch.id IS '主键';
  573. COMMENT ON COLUMN sj_job_task_batch.namespace_id IS '命名空间id';
  574. COMMENT ON COLUMN sj_job_task_batch.group_name IS '组名称';
  575. COMMENT ON COLUMN sj_job_task_batch.job_id IS '任务id';
  576. COMMENT ON COLUMN sj_job_task_batch.workflow_node_id IS '工作流节点id';
  577. COMMENT ON COLUMN sj_job_task_batch.parent_workflow_node_id IS '工作流任务父批次id';
  578. COMMENT ON COLUMN sj_job_task_batch.workflow_task_batch_id IS '工作流任务批次id';
  579. COMMENT ON COLUMN sj_job_task_batch.task_batch_status IS '任务批次状态 0、失败 1、成功';
  580. COMMENT ON COLUMN sj_job_task_batch.operation_reason IS '操作原因';
  581. COMMENT ON COLUMN sj_job_task_batch.execution_at IS '任务执行时间';
  582. COMMENT ON COLUMN sj_job_task_batch.system_task_type IS '任务类型 3、JOB任务 4、WORKFLOW任务';
  583. COMMENT ON COLUMN sj_job_task_batch.parent_id IS '父节点';
  584. COMMENT ON COLUMN sj_job_task_batch.ext_attrs IS '扩展字段';
  585. COMMENT ON COLUMN sj_job_task_batch.deleted IS '逻辑删除 1、删除';
  586. COMMENT ON COLUMN sj_job_task_batch.create_dt IS '创建时间';
  587. COMMENT ON COLUMN sj_job_task_batch.update_dt IS '修改时间';
  588. COMMENT ON TABLE sj_job_task_batch IS '任务批次';
  589. -- sj_job_summary
  590. CREATE TABLE sj_job_summary
  591. (
  592. id bigserial PRIMARY KEY,
  593. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  594. group_name varchar(64) NOT NULL DEFAULT '',
  595. business_id bigint NOT NULL,
  596. system_task_type smallint NOT NULL DEFAULT 3,
  597. trigger_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  598. success_num int NOT NULL DEFAULT 0,
  599. fail_num int NOT NULL DEFAULT 0,
  600. fail_reason varchar(512) NOT NULL DEFAULT '',
  601. stop_num int NOT NULL DEFAULT 0,
  602. stop_reason varchar(512) NOT NULL DEFAULT '',
  603. cancel_num int NOT NULL DEFAULT 0,
  604. cancel_reason varchar(512) NOT NULL DEFAULT '',
  605. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  606. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  607. );
  608. CREATE UNIQUE INDEX uk_sj_job_summary_01 ON sj_job_summary (trigger_at, system_task_type, business_id);
  609. CREATE INDEX idx_sj_job_summary_01 ON sj_job_summary (namespace_id, group_name, business_id);
  610. COMMENT ON COLUMN sj_job_summary.id IS '主键';
  611. COMMENT ON COLUMN sj_job_summary.namespace_id IS '命名空间id';
  612. COMMENT ON COLUMN sj_job_summary.group_name IS '组名称';
  613. COMMENT ON COLUMN sj_job_summary.business_id IS '业务id ( job_id或workflow_id)';
  614. COMMENT ON COLUMN sj_job_summary.system_task_type IS '任务类型 3、JOB任务 4、WORKFLOW任务';
  615. COMMENT ON COLUMN sj_job_summary.trigger_at IS '统计时间';
  616. COMMENT ON COLUMN sj_job_summary.success_num IS '执行成功-日志数量';
  617. COMMENT ON COLUMN sj_job_summary.fail_num IS '执行失败-日志数量';
  618. COMMENT ON COLUMN sj_job_summary.fail_reason IS '失败原因';
  619. COMMENT ON COLUMN sj_job_summary.stop_num IS '执行失败-日志数量';
  620. COMMENT ON COLUMN sj_job_summary.stop_reason IS '失败原因';
  621. COMMENT ON COLUMN sj_job_summary.cancel_num IS '执行失败-日志数量';
  622. COMMENT ON COLUMN sj_job_summary.cancel_reason IS '失败原因';
  623. COMMENT ON COLUMN sj_job_summary.create_dt IS '创建时间';
  624. COMMENT ON COLUMN sj_job_summary.update_dt IS '修改时间';
  625. COMMENT ON TABLE sj_job_summary IS 'DashBoard_Job';
  626. -- sj_retry_summary
  627. CREATE TABLE sj_retry_summary
  628. (
  629. id bigserial PRIMARY KEY,
  630. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  631. group_name varchar(64) NOT NULL DEFAULT '',
  632. scene_name varchar(50) NOT NULL DEFAULT '',
  633. trigger_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  634. running_num int NOT NULL DEFAULT 0,
  635. finish_num int NOT NULL DEFAULT 0,
  636. max_count_num int NOT NULL DEFAULT 0,
  637. suspend_num int NOT NULL DEFAULT 0,
  638. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  639. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  640. );
  641. CREATE UNIQUE INDEX uk_sj_retry_summary_01 ON sj_retry_summary (namespace_id, group_name, scene_name, trigger_at);
  642. CREATE INDEX idx_sj_retry_summary_01 ON sj_retry_summary (trigger_at);
  643. COMMENT ON COLUMN sj_retry_summary.id IS '主键';
  644. COMMENT ON COLUMN sj_retry_summary.namespace_id IS '命名空间id';
  645. COMMENT ON COLUMN sj_retry_summary.group_name IS '组名称';
  646. COMMENT ON COLUMN sj_retry_summary.scene_name IS '场景名称';
  647. COMMENT ON COLUMN sj_retry_summary.trigger_at IS '统计时间';
  648. COMMENT ON COLUMN sj_retry_summary.running_num IS '重试中-日志数量';
  649. COMMENT ON COLUMN sj_retry_summary.finish_num IS '重试完成-日志数量';
  650. COMMENT ON COLUMN sj_retry_summary.max_count_num IS '重试到达最大次数-日志数量';
  651. COMMENT ON COLUMN sj_retry_summary.suspend_num IS '暂停重试-日志数量';
  652. COMMENT ON COLUMN sj_retry_summary.create_dt IS '创建时间';
  653. COMMENT ON COLUMN sj_retry_summary.update_dt IS '修改时间';
  654. COMMENT ON TABLE sj_retry_summary IS 'DashBoard_Retry';
  655. -- sj_workflow
  656. CREATE TABLE sj_workflow
  657. (
  658. id bigserial PRIMARY KEY,
  659. workflow_name varchar(64) NOT NULL,
  660. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  661. group_name varchar(64) NOT NULL,
  662. workflow_status smallint NOT NULL DEFAULT 1,
  663. trigger_type smallint NOT NULL,
  664. trigger_interval varchar(255) NOT NULL,
  665. next_trigger_at bigint NOT NULL,
  666. block_strategy smallint NOT NULL DEFAULT 1,
  667. executor_timeout int NOT NULL DEFAULT 0,
  668. description varchar(256) NOT NULL DEFAULT '',
  669. flow_info text NULL DEFAULT NULL,
  670. wf_context text NULL DEFAULT NULL,
  671. notify_ids varchar(128) NOT NULL DEFAULT '',
  672. bucket_index int NOT NULL DEFAULT 0,
  673. version int NOT NULL,
  674. ext_attrs varchar(256) NULL DEFAULT '',
  675. deleted smallint NOT NULL DEFAULT 0,
  676. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  677. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  678. );
  679. CREATE INDEX idx_sj_workflow_01 ON sj_workflow (create_dt);
  680. CREATE INDEX idx_sj_workflow_02 ON sj_workflow (namespace_id, group_name);
  681. COMMENT ON COLUMN sj_workflow.id IS '主键';
  682. COMMENT ON COLUMN sj_workflow.workflow_name IS '工作流名称';
  683. COMMENT ON COLUMN sj_workflow.namespace_id IS '命名空间id';
  684. COMMENT ON COLUMN sj_workflow.group_name IS '组名称';
  685. COMMENT ON COLUMN sj_workflow.workflow_status IS '工作流状态 0、关闭、1、开启';
  686. COMMENT ON COLUMN sj_workflow.trigger_type IS '触发类型 1.CRON 表达式 2. 固定时间';
  687. COMMENT ON COLUMN sj_workflow.trigger_interval IS '间隔时长';
  688. COMMENT ON COLUMN sj_workflow.next_trigger_at IS '下次触发时间';
  689. COMMENT ON COLUMN sj_workflow.block_strategy IS '阻塞策略 1、丢弃 2、覆盖 3、并行';
  690. COMMENT ON COLUMN sj_workflow.executor_timeout IS '任务执行超时时间,单位秒';
  691. COMMENT ON COLUMN sj_workflow.description IS '描述';
  692. COMMENT ON COLUMN sj_workflow.flow_info IS '流程信息';
  693. COMMENT ON COLUMN sj_workflow.wf_context IS '上下文';
  694. COMMENT ON COLUMN sj_workflow.notify_ids IS '通知告警场景配置id列表';
  695. COMMENT ON COLUMN sj_workflow.bucket_index IS 'bucket';
  696. COMMENT ON COLUMN sj_workflow.version IS '版本号';
  697. COMMENT ON COLUMN sj_workflow.ext_attrs IS '扩展字段';
  698. COMMENT ON COLUMN sj_workflow.deleted IS '逻辑删除 1、删除';
  699. COMMENT ON COLUMN sj_workflow.create_dt IS '创建时间';
  700. COMMENT ON COLUMN sj_workflow.update_dt IS '修改时间';
  701. COMMENT ON TABLE sj_workflow IS '工作流';
  702. -- sj_workflow_node
  703. CREATE TABLE sj_workflow_node
  704. (
  705. id bigserial PRIMARY KEY,
  706. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  707. node_name varchar(64) NOT NULL,
  708. group_name varchar(64) NOT NULL,
  709. job_id bigint NOT NULL,
  710. workflow_id bigint NOT NULL,
  711. node_type smallint NOT NULL DEFAULT 1,
  712. expression_type smallint NOT NULL DEFAULT 0,
  713. fail_strategy smallint NOT NULL DEFAULT 1,
  714. workflow_node_status smallint NOT NULL DEFAULT 1,
  715. priority_level int NOT NULL DEFAULT 1,
  716. node_info text NULL DEFAULT NULL,
  717. version int NOT NULL,
  718. ext_attrs varchar(256) NULL DEFAULT '',
  719. deleted smallint NOT NULL DEFAULT 0,
  720. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  721. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  722. );
  723. CREATE INDEX idx_sj_workflow_node_01 ON sj_workflow_node (create_dt);
  724. CREATE INDEX idx_sj_workflow_node_02 ON sj_workflow_node (namespace_id, group_name);
  725. COMMENT ON COLUMN sj_workflow_node.id IS '主键';
  726. COMMENT ON COLUMN sj_workflow_node.namespace_id IS '命名空间id';
  727. COMMENT ON COLUMN sj_workflow_node.node_name IS '节点名称';
  728. COMMENT ON COLUMN sj_workflow_node.group_name IS '组名称';
  729. COMMENT ON COLUMN sj_workflow_node.job_id IS '任务信息id';
  730. COMMENT ON COLUMN sj_workflow_node.workflow_id IS '工作流ID';
  731. COMMENT ON COLUMN sj_workflow_node.node_type IS '1、任务节点 2、条件节点';
  732. COMMENT ON COLUMN sj_workflow_node.expression_type IS '1、SpEl、2、Aviator 3、QL';
  733. COMMENT ON COLUMN sj_workflow_node.fail_strategy IS '失败策略 1、跳过 2、阻塞';
  734. COMMENT ON COLUMN sj_workflow_node.workflow_node_status IS '工作流节点状态 0、关闭、1、开启';
  735. COMMENT ON COLUMN sj_workflow_node.priority_level IS '优先级';
  736. COMMENT ON COLUMN sj_workflow_node.node_info IS '节点信息 ';
  737. COMMENT ON COLUMN sj_workflow_node.version IS '版本号';
  738. COMMENT ON COLUMN sj_workflow_node.ext_attrs IS '扩展字段';
  739. COMMENT ON COLUMN sj_workflow_node.deleted IS '逻辑删除 1、删除';
  740. COMMENT ON COLUMN sj_workflow_node.create_dt IS '创建时间';
  741. COMMENT ON COLUMN sj_workflow_node.update_dt IS '修改时间';
  742. COMMENT ON TABLE sj_workflow_node IS '工作流节点';
  743. -- sj_workflow_task_batch
  744. CREATE TABLE sj_workflow_task_batch
  745. (
  746. id bigserial PRIMARY KEY,
  747. namespace_id varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
  748. group_name varchar(64) NOT NULL,
  749. workflow_id bigint NOT NULL,
  750. task_batch_status smallint NOT NULL DEFAULT 0,
  751. operation_reason smallint NOT NULL DEFAULT 0,
  752. flow_info text NULL DEFAULT NULL,
  753. wf_context text NULL DEFAULT NULL,
  754. execution_at bigint NOT NULL DEFAULT 0,
  755. ext_attrs varchar(256) NULL DEFAULT '',
  756. version int NOT NULL DEFAULT 1,
  757. deleted smallint NOT NULL DEFAULT 0,
  758. create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  759. update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  760. );
  761. CREATE INDEX idx_sj_workflow_task_batch_01 ON sj_workflow_task_batch (workflow_id, task_batch_status);
  762. CREATE INDEX idx_sj_workflow_task_batch_02 ON sj_workflow_task_batch (create_dt);
  763. CREATE INDEX idx_sj_workflow_task_batch_03 ON sj_workflow_task_batch (namespace_id, group_name);
  764. COMMENT ON COLUMN sj_workflow_task_batch.id IS '主键';
  765. COMMENT ON COLUMN sj_workflow_task_batch.namespace_id IS '命名空间id';
  766. COMMENT ON COLUMN sj_workflow_task_batch.group_name IS '组名称';
  767. COMMENT ON COLUMN sj_workflow_task_batch.workflow_id IS '工作流任务id';
  768. COMMENT ON COLUMN sj_workflow_task_batch.task_batch_status IS '任务批次状态 0、失败 1、成功';
  769. COMMENT ON COLUMN sj_workflow_task_batch.operation_reason IS '操作原因';
  770. COMMENT ON COLUMN sj_workflow_task_batch.flow_info IS '流程信息';
  771. COMMENT ON COLUMN sj_workflow_task_batch.wf_context IS '全局上下文';
  772. COMMENT ON COLUMN sj_workflow_task_batch.execution_at IS '任务执行时间';
  773. COMMENT ON COLUMN sj_workflow_task_batch.ext_attrs IS '扩展字段';
  774. COMMENT ON COLUMN sj_workflow_task_batch.version IS '版本号';
  775. COMMENT ON COLUMN sj_workflow_task_batch.deleted IS '逻辑删除 1、删除';
  776. COMMENT ON COLUMN sj_workflow_task_batch.create_dt IS '创建时间';
  777. COMMENT ON COLUMN sj_workflow_task_batch.update_dt IS '修改时间';
  778. COMMENT ON TABLE sj_workflow_task_batch IS '工作流批次';