feat: implement wiki and wiki content management system including database schemas, DTOs, and API endpoints
All checks were successful
Build and Release / release (push) Successful in 1m33s
All checks were successful
Build and Release / release (push) Successful in 1m33s
This commit is contained in:
@@ -5,7 +5,6 @@ CREATE TABLE IF NOT EXISTS wikis (
|
||||
project_id UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
||||
title TEXT,
|
||||
slug TEXT,
|
||||
content TEXT,
|
||||
is_deleted BOOLEAN NOT NULL DEFAULT false,
|
||||
created_at TIMESTAMPTZ DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ DEFAULT now()
|
||||
|
||||
1
db/migrations/000016_wiki_content.down.sql
Normal file
1
db/migrations/000016_wiki_content.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS wiki_content;
|
||||
11
db/migrations/000016_wiki_content.up.sql
Normal file
11
db/migrations/000016_wiki_content.up.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS wiki_content (
|
||||
id UUID PRIMARY KEY DEFAULT uuidv7(),
|
||||
wiki_id UUID NOT NULL REFERENCES wikis(id) ON DELETE CASCADE,
|
||||
title TEXT NOT NULL,
|
||||
content TEXT,
|
||||
is_deleted BOOLEAN NOT NULL DEFAULT false,
|
||||
created_at TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_wiki_content_wiki_id ON wiki_content(wiki_id);
|
||||
CREATE INDEX idx_wiki_content_created_at ON wiki_content(created_at DESC);
|
||||
@@ -1,8 +1,8 @@
|
||||
-- name: CreateWiki :one
|
||||
INSERT INTO wikis (
|
||||
id, title, slug, content, project_id
|
||||
id, title, slug, project_id
|
||||
) VALUES (
|
||||
COALESCE(sqlc.narg('id')::uuid, uuidv7()), $1, $2, $3, $4
|
||||
COALESCE(sqlc.narg('id')::uuid, uuidv7()), $1, $2, $3
|
||||
)
|
||||
RETURNING *;
|
||||
|
||||
@@ -16,7 +16,6 @@ UPDATE wikis
|
||||
SET
|
||||
title = COALESCE(sqlc.narg('title'), title),
|
||||
slug = COALESCE(sqlc.narg('slug'), slug),
|
||||
content = COALESCE(sqlc.narg('content'), content),
|
||||
project_id = COALESCE(sqlc.narg('project_id'), project_id)
|
||||
WHERE id = sqlc.arg('id') AND is_deleted = false
|
||||
RETURNING *;
|
||||
@@ -93,3 +92,38 @@ WHERE slug = $1 AND is_deleted = false;
|
||||
|
||||
-- name: GetWikisBySlugs :many
|
||||
SELECT * FROM wikis WHERE slug = ANY($1::text[]) AND is_deleted = false;
|
||||
|
||||
-- name: CreateWikiContent :one
|
||||
INSERT INTO wiki_content (
|
||||
id, wiki_id, title, content
|
||||
) VALUES (
|
||||
COALESCE(sqlc.narg('id')::uuid, uuidv7()), $1, $2, $3
|
||||
)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetWikiContentCount :one
|
||||
SELECT COUNT(*)
|
||||
FROM wiki_content
|
||||
WHERE wiki_id = $1;
|
||||
|
||||
-- name: GetWikiContentById :one
|
||||
SELECT *
|
||||
FROM wiki_content
|
||||
WHERE id = $1 AND is_deleted = false;
|
||||
|
||||
-- name: GetWikiContentByIDs :many
|
||||
SELECT *
|
||||
FROM wiki_content
|
||||
WHERE id = ANY($1::uuid[]) AND is_deleted = false;
|
||||
|
||||
-- name: GetWikiContentByWikiID :many
|
||||
SELECT id, title, created_at
|
||||
FROM wiki_content
|
||||
WHERE wiki_id = $1 AND is_deleted = false
|
||||
ORDER BY created_at DESC;
|
||||
|
||||
-- name: GetWikiContentByWikiIDs :many
|
||||
SELECT id, wiki_id, title, created_at
|
||||
FROM wiki_content
|
||||
WHERE wiki_id = ANY($1::uuid[]) AND is_deleted = false
|
||||
ORDER BY created_at DESC;
|
||||
|
||||
@@ -102,12 +102,20 @@ CREATE TABLE IF NOT EXISTS wikis (
|
||||
project_id UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
||||
title TEXT,
|
||||
slug TEXT UNIQUE,
|
||||
content TEXT,
|
||||
is_deleted BOOLEAN NOT NULL DEFAULT false,
|
||||
created_at TIMESTAMPTZ DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS wiki_content (
|
||||
id UUID PRIMARY KEY DEFAULT uuidv7(),
|
||||
wiki_id UUID NOT NULL REFERENCES wikis(id) ON DELETE CASCADE,
|
||||
title TEXT NOT NULL,
|
||||
content TEXT,
|
||||
is_deleted BOOLEAN NOT NULL DEFAULT false,
|
||||
created_at TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS entity_wikis (
|
||||
entity_id UUID REFERENCES entities(id) ON DELETE CASCADE,
|
||||
wiki_id UUID REFERENCES wikis(id) ON DELETE CASCADE,
|
||||
|
||||
Reference in New Issue
Block a user