21 lines
869 B
SQL
21 lines
869 B
SQL
CREATE TABLE IF NOT EXISTS posts (
|
|
id BIGSERIAL,
|
|
title VARCHAR(255) NOT NULL,
|
|
content TEXT NOT NULL,
|
|
cover_id BIGINT,
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
COMMENT ON TABLE posts IS 'Blog posts table';
|
|
|
|
COMMENT ON COLUMN posts.id IS 'Unique identifier for the post';
|
|
COMMENT ON COLUMN posts.title IS 'Title of the blog post';
|
|
COMMENT ON COLUMN posts.content IS 'Content of the blog post';
|
|
COMMENT ON COLUMN posts.cover_id IS 'Reference to the cover image file id';
|
|
COMMENT ON COLUMN posts.created_at IS 'Timestamp when the post was created';
|
|
COMMENT ON COLUMN posts.updated_at IS 'Timestamp when the post was last updated';
|
|
|
|
CREATE INDEX idx_posts_created_at ON posts(created_at);
|
|
CREATE INDEX idx_posts_cover_id ON posts(cover_id); |