From 8702f23e18b49035a8f74c8fee894728fa6220a3 Mon Sep 17 00:00:00 2001
From: cflip <36554078+cflip@users.noreply.github.com>
Date: Wed, 7 Apr 2021 11:38:09 -0600
Subject: Update SQL script

---
 setup.sql | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

(limited to 'setup.sql')

diff --git a/setup.sql b/setup.sql
index f51250b..a826cd3 100644
--- a/setup.sql
+++ b/setup.sql
@@ -11,6 +11,8 @@ CREATE TABLE categories (
 	cat_id INT(8) NOT NULL AUTO_INCREMENT,
 	cat_name VARCHAR(255) NOT NULL,
 	cat_description VARCHAR(255) NOT NULL,
+	cat_thread_count INT(8) NOT NULL DEFAULT 0,
+	cat_post_count INT(8) NOT NULL DEFAULT 0,
 	UNIQUE INDEX cat_name_unique (cat_name),
 	PRIMARY KEY (cat_id)
 ) ENGINE = InnoDB;
@@ -18,8 +20,9 @@ CREATE TABLE categories (
 CREATE TABLE threads (
 	thread_id INT(8) NOT NULL AUTO_INCREMENT,
 	thread_subject VARCHAR(255) NOT NULL,
-	thread_date DATETIME NOT NULL,
-	thread_cat INT(8) NOT NULL,
+	thread_date_created DATETIME NOT NULL,
+	thread_date_lastpost DATETIME NOT NULL,
+	thread_category INT(8) NOT NULL,
 	thread_author INT(8) NOT NULL,
 	PRIMARY KEY (thread_id)
 ) ENGINE = InnoDB;
@@ -33,7 +36,7 @@ CREATE TABLE posts (
 	PRIMARY KEY (post_id)
 ) ENGINE = InnoDB;
 
-ALTER TABLE threads ADD FOREIGN KEY(thread_cat) REFERENCES categories(cat_id) ON DELETE CASCADE ON UPDATE CASCADE;
+ALTER TABLE threads ADD FOREIGN KEY(thread_category) REFERENCES categories(cat_id) ON DELETE CASCADE ON UPDATE CASCADE;
 ALTER TABLE threads ADD FOREIGN KEY(thread_author) REFERENCES users(user_id) ON DELETE RESTRICT ON UPDATE CASCADE;
 ALTER TABLE posts ADD FOREIGN KEY(post_thread) REFERENCES threads(thread_id) ON DELETE CASCADE ON UPDATE CASCADE;
 ALTER TABLE posts ADD FOREIGN KEY(post_author) REFERENCES users(user_id) ON DELETE RESTRICT ON UPDATE CASCADE;
-- 
cgit v1.2.3

