Tasks query API, yay!
This commit is contained in:
@@ -0,0 +1 @@
|
||||
DROP TYPE task_schedule;
|
||||
@@ -0,0 +1 @@
|
||||
CREATE TYPE task_schedule AS ENUM('once', 'daily', 'weekly', 'monthly', 'yearly');
|
||||
1
sql/migrations/patches/20191007000601-tasks/down.sql
Normal file
1
sql/migrations/patches/20191007000601-tasks/down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE tasks;
|
||||
14
sql/migrations/patches/20191007000601-tasks/up.sql
Normal file
14
sql/migrations/patches/20191007000601-tasks/up.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE tasks (
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
owner integer NOT NULL REFERENCES users(id),
|
||||
name text NOT NULL,
|
||||
notes text,
|
||||
schedule task_schedule NOT NULL DEFAULT 'daily',
|
||||
min_frequency integer,
|
||||
max_frequency integer,
|
||||
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CHECK(min_frequency IS NULL OR max_frequency IS NULL OR max_frequency > min_frequency)
|
||||
);
|
||||
|
||||
CREATE TRIGGER set_tasks_updated BEFORE UPDATE ON tasks FOR EACH ROW EXECUTE PROCEDURE set_updated_timestamp();
|
||||
14
sql/tasks/list.sql
Normal file
14
sql/tasks/list.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
notes,
|
||||
schedule,
|
||||
min_frequency,
|
||||
max_frequency,
|
||||
created_at
|
||||
FROM
|
||||
tasks
|
||||
WHERE
|
||||
owner = $1
|
||||
ORDER BY created_at ASC
|
||||
LIMIT $2 OFFSET $3;
|
||||
Reference in New Issue
Block a user