服务端
库名: scheduler
create table scheduler.task
(
	id varchar(50) not null
		constraint task_pkey
			primary key,
	task_name varchar(255) not null,
	task_cmd text,
	task_param text,
	task_status smallint default 0 not null,
	task_result_json text,
	task_sent_time bigint,
	task_last_client varchar(255),
	task_expected_finish_time bigint,
	create_time timestamp(0) with time zone default CURRENT_TIMESTAMP,
	last_update timestamp(0) with time zone default CURRENT_TIMESTAMP,
	project_id varchar(80),
	model_id varchar(80)
);

comment on table scheduler.task is '任务表';

comment on column scheduler.task.task_status is '0 Waiting, 1 Sending, 2 Sent, 3 FileDownloadException, 4 CommandExecuteException, 5 Finished';

comment on column scheduler.task.task_sent_time is '客户端成功接收任务的时间';

comment on column scheduler.task.task_expected_finish_time is '预期完成时间, 单位是s';

alter table scheduler.task owner to postgres;

create index task_status_index
	on scheduler.task (task_status);

--
-- CREATE TABLE scheduler.task
-- (
--     id serial NOT NULL,
--     task_name character varying(255) COLLATE pg_catalog."default" NOT NULL,
--     task_cmd text COLLATE pg_catalog."default" default NULL,
--     task_param text COLLATE pg_catalog."default" default NULL,
--     task_status smallint not null default 0,
-- 	task_result_json text COLLATE pg_catalog."default" default NULL,
-- 	task_sent_time bigint default null,
--     task_last_client character varying(255) COLLATE pg_catalog."default" default null,
-- 	task_expected_finish_time bigint NOT NULL,
-- -- 	task_add_time timestamp(0) with time zone DEFAULT CURRENT_TIMESTAMP,
--     create_time timestamp(0) with time zone DEFAULT CURRENT_TIMESTAMP,
-- 	last_update timestamp(0) with time zone DEFAULT CURRENT_TIMESTAMP,
--     CONSTRAINT task_pkey PRIMARY KEY (id)
-- )
-- WITH (
--     OIDS = FALSE
-- )
-- TABLESPACE pg_default;
--
-- ALTER TABLE scheduler.task
--     OWNER to postgres;
-- COMMENT ON TABLE scheduler.task
--     IS '任务表';
--
-- COMMENT ON COLUMN scheduler.task.task_status
--     IS '0 Waiting, 1 Sending, 2 Sent, 3 FileDownloadException, 4 CommandExecuteException, 5 Finished';
--
-- COMMENT ON COLUMN scheduler.task.task_sent_time
--     IS '客户端成功接收任务的时间, 单位是s';
--
-- COMMENT ON COLUMN scheduler.task.task_expected_finish_time
--     IS '预期完成时间, 单位是s';
--
-- CREATE INDEX task_status_index ON scheduler.task(task_status);
--
--

CREATE TABLE scheduler.download
(
    task_id varchar(50) not null,
    task_url character varying(255) COLLATE pg_catalog."default" default NULL,
    task_md5 character varying(40) COLLATE pg_catalog."default" default NULL,
	create_time timestamp(0) with time zone DEFAULT CURRENT_TIMESTAMP,
	last_update timestamp(0) with time zone DEFAULT CURRENT_TIMESTAMP,
    CONSTRAINT download_pkey PRIMARY KEY (task_id)
)
WITH (
    OIDS = FALSE
)
TABLESPACE pg_default;

ALTER TABLE scheduler.download
    OWNER to postgres;




create table scheduler.task_result
(
	task_id varchar(50) not null
		constraint task_result_pk
			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;



