summaryrefslogtreecommitdiff
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/README.md9
-rw-r--r--meta/config.example.ini5
-rw-r--r--meta/setup.sql44
3 files changed, 58 insertions, 0 deletions
diff --git a/meta/README.md b/meta/README.md
new file mode 100644
index 0000000..80c9d54
--- /dev/null
+++ b/meta/README.md
@@ -0,0 +1,9 @@
+# cflip.net forums
+The source code to my first PHP project, a forum system.
+
+## Requirements
+This project requires PHP 7.0 or newer
+
+## Setup
+- Create a `config.ini` file and put your MySQL credentials in (see `config.example.ini`)
+- `setup.sql` has the SQL script to set up your database.
diff --git a/meta/config.example.ini b/meta/config.example.ini
new file mode 100644
index 0000000..c587a63
--- /dev/null
+++ b/meta/config.example.ini
@@ -0,0 +1,5 @@
+[mysql_credentials]
+server = ""
+database = ""
+user = ""
+password = "" \ No newline at end of file
diff --git a/meta/setup.sql b/meta/setup.sql
new file mode 100644
index 0000000..6a96b8a
--- /dev/null
+++ b/meta/setup.sql
@@ -0,0 +1,44 @@
+CREATE TABLE users (
+ user_id INT(8) NOT NULL AUTO_INCREMENT,
+ user_name VARCHAR(30) NOT NULL,
+ user_pass VARCHAR(255) NOT NULL,
+ user_level INT(8) NOT NULL DEFAULT 0,
+ user_date DATETIME NOT NULL,
+ UNIQUE INDEX user_name_unique (user_name),
+ PRIMARY KEY (user_id)
+) ENGINE = InnoDB;
+
+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;
+
+CREATE TABLE threads (
+ thread_id INT(8) NOT NULL AUTO_INCREMENT,
+ thread_subject VARCHAR(255) 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;
+
+CREATE TABLE posts (
+ post_id INT(8) NOT NULL AUTO_INCREMENT,
+ post_content TEXT NOT NULL,
+ post_date_created DATETIME NOT NULL,
+ post_date_edited DATETIME,
+ post_thread INT(8) NOT NULL,
+ post_author INT(8) NOT NULL,
+ PRIMARY KEY (post_id)
+) ENGINE = InnoDB;
+
+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;