Added pretty much everything except discussion forums
This commit is contained in:
34
api/migrations/sqls/20260222232949-discussion-posts-up.sql
Normal file
34
api/migrations/sqls/20260222232949-discussion-posts-up.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
/* Replace with your SQL commands */
|
||||
CREATE TABLE discussion_posts (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
type VARCHAR(50) NOT NULL,
|
||||
poster_id INT NOT NULL,
|
||||
title VARCHAR(100) NOT NULL,
|
||||
content JSON NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
is_deleted BOOLEAN DEFAULT FALSE,
|
||||
is_locked BOOLEAN DEFAULT FALSE,
|
||||
is_open BOOLEAN GENERATED ALWAYS AS (
|
||||
NOT is_deleted
|
||||
AND NOT is_locked
|
||||
) STORED,
|
||||
FOREIGN KEY (poster_id) REFERENCES members(id) ON DELETE CASCADE
|
||||
);
|
||||
CREATE TABLE discussion_comments (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
post_id INT NOT NULL,
|
||||
poster_id INT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
is_deleted BOOLEAN DEFAULT FALSE,
|
||||
FOREIGN KEY (post_id) REFERENCES discussion_posts(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (poster_id) REFERENCES members(id) ON DELETE CASCADE
|
||||
);
|
||||
CREATE INDEX idx_discussion_posts_title ON discussion_posts(title);
|
||||
CREATE INDEX idx_discussion_posts_type ON discussion_posts(type);
|
||||
CREATE INDEX idx_discussion_posts_poster_id ON discussion_posts(poster_id);
|
||||
CREATE INDEX idx_discussion_comments_post_id ON discussion_comments(post_id);
|
||||
CREATE INDEX idx_discussion_comments_poster_id ON discussion_comments(poster_id);
|
||||
CREATE INDEX idx_discussion_posts_is_open ON discussion_posts(is_open);
|
||||
Reference in New Issue
Block a user