From 63cd4651890f3c2bcc9533fb53de61c81beb03b3 Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Tue, 3 Mar 2026 13:46:06 +0000 Subject: [PATCH] feat(db): add status and constraints to the schema --- server/db/schema.sql | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server/db/schema.sql b/server/db/schema.sql index 5a9eaee..5379a95 100644 --- a/server/db/schema.sql +++ b/server/db/schema.sql @@ -11,9 +11,19 @@ CREATE TABLE datasets ( user_id INTEGER NOT NULL, name VARCHAR(255) NOT NULL, description TEXT, + + -- Job state machine + status TEXT NOT NULL DEFAULT 'processing', + status_message TEXT, + completed_at TIMESTAMP, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, topics JSONB, - FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + + -- Enforce valid states + CONSTRAINT datasets_status_check + CHECK (status IN ('processing', 'complete', 'error')) ); CREATE TABLE events (