
CREATE TABLE IF NOT EXISTS "infra_config" (
    "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY,
    "group" varchar(50) NOT NULL,
    "type" tinyint NOT NULL,
    "name" varchar(100) NOT NULL DEFAULT '',
    "key" varchar(100) NOT NULL DEFAULT '',
    "value" varchar(500) NOT NULL DEFAULT '',
    "sensitive" bit NOT NULL,
    "remark" varchar(500) DEFAULT NULL,
    "creator" varchar(64) DEFAULT '',
    "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updater" varchar(64) DEFAULT '',
    "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "deleted" bit NOT NULL DEFAULT FALSE,
    PRIMARY KEY ("id")
    ) COMMENT '参数配置表';

CREATE TABLE IF NOT EXISTS "infra_file" (
    "id" varchar(188) NOT NULL,
    "type" varchar(63) DEFAULT NULL,
    "content" blob NOT NULL,
    "creator" varchar(64) DEFAULT '',
    "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updater" varchar(64) DEFAULT '',
    "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "deleted" bit NOT NULL DEFAULT FALSE,
    "tenant_id" bigint not null default  '0',
    PRIMARY KEY ("id")
    ) COMMENT '文件表';

CREATE TABLE IF NOT EXISTS "infra_job" (
    "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '任务编号',
    "name" varchar(32) NOT NULL COMMENT '任务名称',
    "status" tinyint(4) NOT NULL COMMENT '任务状态',
    "handler_name" varchar(64) NOT NULL COMMENT '处理器的名字',
    "handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数',
    "cron_expression" varchar(32) NOT NULL COMMENT 'CRON 表达式',
    "retry_count" int(11) NOT NULL DEFAULT '0' COMMENT '重试次数',
    "retry_interval" int(11) NOT NULL DEFAULT '0' COMMENT '重试间隔',
    "monitor_timeout" int(11) NOT NULL DEFAULT '0' COMMENT '监控超时时间',
    "creator" varchar(64) DEFAULT '' COMMENT '创建者',
    "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    "updater" varchar(64) DEFAULT '' COMMENT '更新者',
    "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    "deleted" bit NOT NULL DEFAULT FALSE COMMENT '是否删除',
    PRIMARY KEY ("id")
    ) COMMENT='定时任务表';

CREATE TABLE IF NOT EXISTS "infra_job_log" (
    "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '日志编号',
    "job_id" bigint(20) NOT NULL COMMENT '任务编号',
    "handler_name" varchar(64) NOT NULL COMMENT '处理器的名字',
    "handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数',
    "execute_index" tinyint(4) NOT NULL DEFAULT '1' COMMENT '第几次执行',
    "begin_time" datetime NOT NULL COMMENT '开始执行时间',
    "end_time" datetime DEFAULT NULL COMMENT '结束执行时间',
    "duration" int(11) DEFAULT NULL COMMENT '执行时长',
    "status" tinyint(4) NOT NULL COMMENT '任务状态',
    "result" varchar(4000) DEFAULT '' COMMENT '结果数据',
    "creator" varchar(64) DEFAULT '' COMMENT '创建者',
    "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    "updater" varchar(64) DEFAULT '' COMMENT '更新者',
    "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    "deleted" bit(1) NOT NULL DEFAULT FALSE COMMENT '是否删除',
    PRIMARY KEY ("id")
    )COMMENT='定时任务日志表';
