服务端
库名: scheduler
create table if not exists `task`(
	`id` varchar(50),
    `task_name` varchar(255),
    `task_cmd` text,
    `task_param` text,
    `task_status` int DEFAULT 0 comment '0 Waiting, 1 Sending, 2 Sent, 3 FileDownloadException, 4 CommandExecuteException, 5 Finished',
    `task_result_json` text,
	`task_sent_time` long comment '客户端成功接收任务的时间',
    `task_last_client` varchar(255),
    `task_expected_finish_time` int comment '预期完成时间, 单位是s',
	`task_add_time` timestamp DEFAULT CURRENT_TIMESTAMP,
	`project_id` varchar(80),
	`model_id` varchar(80),
    PRIMARY KEY (`id`),
	index statusIndex(task_status)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

create table if not exists `download`(
    `task_id` varchar(50),
    `task_url` varchar(255),
    `task_md5` varchar(40),
    PRIMARY KEY (`task_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;


客户端
库名: worker
create table if not exists `task`(
	`tid` int NOT NULL AUTO_INCREMENT,
	`id` int NOT NULL,
    `task_name` varchar(255),
    `task_cmd` text,
    `task_param` text,
    `task_status` int comment '0 Waiting, 1 Success, -1 downloadError, -2 execute error',
    `task_result_json` text,
	`task_expected_finish_time` int comment '预期完成时间, 单位是s',
	`task_add_time` timestamp DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`tid`),
	index taskIdIndex(id),
	index statusIndex(task_status)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

create table if not exists `download`(
	`tid` int NOT NULL AUTO_INCREMENT,
	`id` int NOT NULL comment '服务器端下载任务id',
    `task_id` int,
    `task_url` varchar(255),
    `local_dir` text,
    `downloaded_bytes` long,
    `file_bytes` long,
    `finish_time` long,
    `task_md5` varchar(40),
    PRIMARY KEY (`tid`),
	index taskIdIndex(task_id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;








create table scheduler.task_result
(
	task_id varchar(50) not null primary key,
	content text,
	create_time timestamp with time zone default CURRENT_TIMESTAMP,
	last_update timestamp with time zone default CURRENT_TIMESTAMP
);

comment on table scheduler.task_result is '任务返回结果';

comment on column scheduler.task_result.task_id is '任务id';

alter table scheduler.task_result owner to postgres;

create index task_result_task_id_index
	on scheduler.task_result (task_id);

