create table sj_job
(
    id               bigint unsigned auto_increment comment '主键'
        primary key,
    namespace_id     varchar(64)  default '764d604ec6fc45f68cd92514c40e9e1a' not null comment '命名空间id',
    group_name       varchar(64)                                             not null comment '组名称',
    job_name         varchar(64)                                             not null comment '名称',
    args_str         text                                                    null comment '执行方法参数',
    args_type        tinyint      default 1                                  not null comment '参数类型 ',
    next_trigger_at  bigint                                                  not null comment '下次触发时间',
    job_status       tinyint      default 1                                  not null comment '任务状态 0、关闭、1、开启',
    task_type        tinyint      default 1                                  not null comment '任务类型 1、集群 2、广播 3、切片',
    route_key        tinyint      default 4                                  not null comment '路由策略',
    executor_type    tinyint      default 1                                  not null comment '执行器类型',
    executor_info    varchar(255)                                            null comment '执行器名称',
    trigger_type     tinyint                                                 not null comment '触发类型 1.CRON 表达式 2. 固定时间',
    trigger_interval varchar(255)                                            not null comment '间隔时长',
    block_strategy   tinyint      default 1                                  not null comment '阻塞策略 1、丢弃 2、覆盖 3、并行 4、恢复',
    executor_timeout int          default 0                                  not null comment '任务执行超时时间，单位秒',
    max_retry_times  int          default 0                                  not null comment '最大重试次数',
    parallel_num     int          default 1                                  not null comment '并行数',
    retry_interval   int          default 0                                  not null comment '重试间隔(s)',
    bucket_index     int          default 0                                  not null comment 'bucket',
    resident         tinyint      default 0                                  not null comment '是否是常驻任务',
    notify_ids       varchar(128) default ''                                 not null comment '通知告警场景配置id列表',
    owner_id         bigint                                                  null comment '负责人id',
    description      varchar(256) default ''                                 not null comment '描述',
    ext_attrs        varchar(256) default ''                                 null comment '扩展字段',
    deleted          tinyint      default 0                                  not null comment '逻辑删除 1、删除',
    create_dt        datetime     default CURRENT_TIMESTAMP                  not null comment '创建时间',
    update_dt        datetime     default CURRENT_TIMESTAMP                  not null on update CURRENT_TIMESTAMP comment '修改时间'
)
    comment '任务信息';

create index idx_create_dt
    on sj_job (create_dt);

create index idx_job_status_bucket_index
    on sj_job (job_status, bucket_index);

create index idx_namespace_id_group_name
    on sj_job (namespace_id, group_name);

INSERT INTO ruoyi.sj_job (id, namespace_id, group_name, job_name, args_str, args_type, next_trigger_at, job_status, task_type, route_key, executor_type, executor_info, trigger_type, trigger_interval, block_strategy, executor_timeout, max_retry_times, parallel_num, retry_interval, bucket_index, resident, notify_ids, owner_id, description, ext_attrs, deleted, create_dt, update_dt) 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, '2025-08-23 21:50:38', '2025-08-23 21:50:38');
