13 lines
709 B
SQL
13 lines
709 B
SQL
CREATE TABLE blogs (
|
|
uuid UUID PRIMARY KEY, -- The blog primary key
|
|
slug VARCHAR(255) UNIQUE NOT NULL, -- Slug must be unique and non-null
|
|
content TEXT NOT NULL, -- Content cannot be null
|
|
label VARCHAR(100), -- Optional label
|
|
author UUID REFERENCES users(user_id) ON DELETE SET NULL, -- Foreign key to user with cascading null for author deletion
|
|
published TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- Automatically set the published time
|
|
summary VARCHAR(500), -- A brief summary of the blog
|
|
image VARCHAR(255), -- URL for the blog image
|
|
href VARCHAR(255), -- Link to the blog if external
|
|
CONSTRAINT check_slug_length CHECK (length(slug) > 0) -- Ensure slug is not empty
|
|
);
|