2020-02-17 09:49:04 +01:00
|
|
|
CREATE TABLE task (
|
2020-01-23 17:53:26 +01:00
|
|
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
|
|
|
|
|
|
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
|
|
|
modified_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
|
|
|
completed_at timestamptz NULL DEFAULT NULL,
|
|
|
|
scheduled_at timestamptz NOT NULL,
|
2020-05-14 23:41:42 +02:00
|
|
|
priority smallint DEFAULT 100,
|
2020-01-23 17:53:26 +01:00
|
|
|
|
2020-01-24 11:58:47 +01:00
|
|
|
queue text NOT NULL,
|
|
|
|
|
2020-01-23 17:53:26 +01:00
|
|
|
name text NOT NULL,
|
|
|
|
props bytea NOT NULL,
|
|
|
|
|
2020-01-24 11:58:47 +01:00
|
|
|
error text NULL DEFAULT NULL,
|
2020-01-23 20:38:21 +01:00
|
|
|
|
2020-01-23 17:53:26 +01:00
|
|
|
retry_num smallint NOT NULL DEFAULT 0,
|
|
|
|
status text NOT NULL DEFAULT 'new'
|
|
|
|
);
|
|
|
|
|
2020-02-17 09:49:04 +01:00
|
|
|
CREATE INDEX task__scheduled_at__queue__idx
|
|
|
|
ON task (scheduled_at, queue);
|
|
|
|
|
|
|
|
CREATE TRIGGER task__modified_at__tgr
|
|
|
|
BEFORE UPDATE ON task
|
|
|
|
FOR EACH ROW EXECUTE PROCEDURE update_modified_at();
|
|
|
|
|
|
|
|
CREATE TABLE scheduled_task (
|
2020-01-25 17:23:21 +01:00
|
|
|
id text PRIMARY KEY,
|
|
|
|
|
|
|
|
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
|
|
|
modified_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
|
|
|
executed_at timestamptz NULL DEFAULT NULL,
|
|
|
|
|
|
|
|
cron_expr text NOT NULL
|
|
|
|
);
|
|
|
|
|
2020-02-17 09:49:04 +01:00
|
|
|
CREATE TRIGGER scheduled_task__modified_at__tgr
|
|
|
|
BEFORE UPDATE ON scheduled_task
|
2020-01-25 17:23:21 +01:00
|
|
|
FOR EACH ROW EXECUTE PROCEDURE update_modified_at();
|