blob: 677d41c613533572c0e123ff110069bb2e0e80b2 [file] [log] [blame]
CREATE TABLE IF NOT EXISTS help_posts (
id INT AUTO_INCREMENT PRIMARY KEY,
author_id INT NOT NULL,
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
like_count INT NOT NULL DEFAULT 0,
reply_count INT NOT NULL DEFAULT 0,
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP()
);
CREATE TABLE IF NOT EXISTS help_comments (
id INT AUTO_INCREMENT PRIMARY KEY,
post_id INT NOT NULL,
author_id INT NOT NULL,
content TEXT NOT NULL,
like_count INT NOT NULL DEFAULT 0,
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(),
CONSTRAINT fk_help_comments_post FOREIGN KEY (post_id) REFERENCES help_posts(id) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS seed_posts (
id INT AUTO_INCREMENT PRIMARY KEY,
author_id INT NOT NULL,
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
like_count INT NOT NULL DEFAULT 0,
reply_count INT NOT NULL DEFAULT 0,
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP()
);
CREATE TABLE IF NOT EXISTS seed_comments (
id INT AUTO_INCREMENT PRIMARY KEY,
post_id INT NOT NULL,
author_id INT NOT NULL,
content TEXT NOT NULL,
like_count INT NOT NULL DEFAULT 0,
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(),
CONSTRAINT fk_seed_comments_post FOREIGN KEY (post_id) REFERENCES seed_posts(id) ON DELETE CASCADE
);