About and database table to convert for the orm

This commit is contained in:
gom-by
2025-01-14 13:49:04 +01:00
parent 0c0e5f80b9
commit 24e3272ab5
8 changed files with 94 additions and 4 deletions

12
database/schemas/blog.sql Normal file
View File

@@ -0,0 +1,12 @@
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
);