27 lines
1.2 KiB
SQL
27 lines
1.2 KiB
SQL
USE vintagecoding;
|
|
DROP TABLE IF EXISTS posts;
|
|
|
|
CREATE TABLE posts (
|
|
post_id INT PRIMARY KEY AUTO_INCREMENT,
|
|
author_id INT NOT NULL,
|
|
post_type_id INT NOT NULL,
|
|
title VARCHAR(255), -- Make title nullable to accommodate Moments and Thoughts
|
|
slug VARCHAR(255) UNIQUE,
|
|
markdown TEXT, -- For Essays
|
|
excerpt VARCHAR(255), -- For Essays
|
|
caption TEXT, -- For Moments
|
|
images TEXT, -- Store image filenames as JSON for Moments
|
|
thought TEXT, -- For Thoughts
|
|
read_count INT DEFAULT 0,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
published_at TIMESTAMP DEFAULT NULL,
|
|
published BOOLEAN DEFAULT TRUE,
|
|
FOREIGN KEY (author_id) REFERENCES user(user_id) ON DELETE CASCADE,
|
|
FOREIGN KEY (post_type_id) REFERENCES post_types(post_type_id)
|
|
);
|
|
|
|
-- Re-insert the initial post, adjusting for the new schema
|
|
INSERT INTO post (author_id, post_type_id, title, excerpt, published_at)
|
|
VALUES (1, 1, 'Building vintagecoding.net', 'A devlog of the creation of vintagecoding.net and a test at the formatting of post cards and posts. Let the great experiment begin!', CURRENT_TIMESTAMP);
|