From cf91911fef2945035d88d11482e1d93b9b620352 Mon Sep 17 00:00:00 2001 From: Jake Meyer Date: Mon, 20 Nov 2023 21:20:22 -0800 Subject: [PATCH] Add task queue migration --- ...16_create_core.down.sql => 0001_create_core.down.sql} | 0 ...021516_create_core.up.sql => 0001_create_core.up.sql} | 0 migrations/0002_create_tasks.down.sql | 1 + migrations/0002_create_tasks.up.sql | 9 +++++++++ 4 files changed, 10 insertions(+) rename migrations/{20221213021516_create_core.down.sql => 0001_create_core.down.sql} (100%) rename migrations/{20221213021516_create_core.up.sql => 0001_create_core.up.sql} (100%) create mode 100644 migrations/0002_create_tasks.down.sql create mode 100644 migrations/0002_create_tasks.up.sql diff --git a/migrations/20221213021516_create_core.down.sql b/migrations/0001_create_core.down.sql similarity index 100% rename from migrations/20221213021516_create_core.down.sql rename to migrations/0001_create_core.down.sql diff --git a/migrations/20221213021516_create_core.up.sql b/migrations/0001_create_core.up.sql similarity index 100% rename from migrations/20221213021516_create_core.up.sql rename to migrations/0001_create_core.up.sql diff --git a/migrations/0002_create_tasks.down.sql b/migrations/0002_create_tasks.down.sql new file mode 100644 index 0000000..87f1ed5 --- /dev/null +++ b/migrations/0002_create_tasks.down.sql @@ -0,0 +1 @@ +DROP TABLE tasks; diff --git a/migrations/0002_create_tasks.up.sql b/migrations/0002_create_tasks.up.sql new file mode 100644 index 0000000..a967b33 --- /dev/null +++ b/migrations/0002_create_tasks.up.sql @@ -0,0 +1,9 @@ +CREATE TABLE tasks( + id UUID NOT NULL PRIMARY KEY, + type TEXT NOT NULL, + priority INT NOT NULL DEFAULT 0, + payload JSONB NOT NULL, + created TIMESTAMPTZ NOT NULL DEFAULT NOW(), + UNIQUE(type, payload) +); +CREATE INDEX tasks_priority_idx ON tasks(priority);