From d0a01c8d2f39bfd3e7a7f2c01cfd39a3bec06805 Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Sun, 1 Mar 2026 15:00:54 +0000 Subject: [PATCH] feat: unify posts and comments tables --- db/schema.sql | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/db/schema.sql b/db/schema.sql index d7c8636..1a0c075 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -12,41 +12,15 @@ CREATE TABLE datasets ( name VARCHAR(255) NOT NULL, description TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - nlp_completed BOOLEAN DEFAULT FALSE, + topics JSONB, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); -CREATE TABLE posts ( +CREATE TABLE events ( id SERIAL PRIMARY KEY, dataset_id INTEGER NOT NULL, - author VARCHAR(255) NOT NULL, - title VARCHAR(255) NOT NULL, - content TEXT NOT NULL, - created_at TIMESTAMP NOT NULL, - source VARCHAR(255) NOT NULL, - - topic VARCHAR(255), - topic_confidence FLOAT, - - ner_entities JSONB, - - emotion_anger FLOAT, - emotion_disgust FLOAT, - emotion_fear FLOAT, - emotion_joy FLOAT, - emotion_neutral FLOAT, - emotion_sadness FLOAT, - emotion_surprise FLOAT, - - FOREIGN KEY (dataset_id) REFERENCES datasets(id) ON DELETE CASCADE -); - -CREATE TABLE comments ( - id SERIAL PRIMARY KEY, - dataset_id INTEGER NOT NULL, - - post_id INTEGER NOT NULL, + parent_post_id INTEGER NOT NULL, author VARCHAR(255) NOT NULL, content TEXT NOT NULL, created_at TIMESTAMP NOT NULL, @@ -62,10 +36,8 @@ CREATE TABLE comments ( emotion_disgust FLOAT, emotion_fear FLOAT, emotion_joy FLOAT, - emotion_neutral FLOAT, emotion_sadness FLOAT, - emotion_surprise FLOAT, - FOREIGN KEY (post_id) REFERENCES posts(id) ON DELETE CASCADE, + FOREIGN KEY (parent_post_id) REFERENCES events(id) ON DELETE CASCADE, FOREIGN KEY (dataset_id) REFERENCES datasets(id) ON DELETE CASCADE ); \ No newline at end of file