UPDATE: new db
All checks were successful
Build and Release / release (push) Successful in 1m30s

This commit is contained in:
2026-05-05 16:57:44 +07:00
parent 8b440ad5c8
commit 29944915cd
25 changed files with 893 additions and 110 deletions

View File

@@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS entities (
id UUID PRIMARY KEY DEFAULT uuidv7(),
project_id UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
name TEXT NOT NULL,
slug TEXT,
slug TEXT UNIQUE,
description TEXT,
status SMALLINT,
time_start INT,
@@ -12,6 +12,9 @@ CREATE TABLE IF NOT EXISTS entities (
updated_at TIMESTAMPTZ DEFAULT now()
);
CREATE UNIQUE INDEX idx_entities_slug_not_deleted
ON entities(slug)
WHERE is_deleted = false;
CREATE INDEX idx_entities_name_search
ON entities USING GIN (name gin_trgm_ops);

View File

@@ -4,12 +4,16 @@ CREATE TABLE IF NOT EXISTS wikis (
id UUID PRIMARY KEY DEFAULT uuidv7(),
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()
);
CREATE UNIQUE INDEX idx_wikis_slug_not_deleted
ON wikis(slug)
WHERE is_deleted = false;
CREATE TABLE IF NOT EXISTS entity_wikis (
entity_id UUID REFERENCES entities(id) ON DELETE CASCADE,

View File

@@ -60,3 +60,8 @@ WHERE project_id = $1 AND is_deleted = false;
UPDATE entities
SET is_deleted = true
WHERE id = ANY($1::uuid[]);
-- name: GetEntityBySlug :one
SELECT *
FROM entities
WHERE slug = $1 AND is_deleted = false;

View File

@@ -1,8 +1,8 @@
-- name: CreateWiki :one
INSERT INTO wikis (
id, title, content, project_id
id, title, slug, content, project_id
) VALUES (
COALESCE(sqlc.narg('id')::uuid, uuidv7()), $1, $2, $3
COALESCE(sqlc.narg('id')::uuid, uuidv7()), $1, $2, $3, $4
)
RETURNING *;
@@ -15,6 +15,7 @@ WHERE id = $1 AND is_deleted = false;
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
@@ -84,3 +85,8 @@ WHERE wiki_id = $1;
-- name: DeleteEntityWiki :exec
DELETE FROM entity_wikis
WHERE entity_id = $1 AND wiki_id = $2;
-- name: GetWikiBySlug :one
SELECT *
FROM wikis
WHERE slug = $1 AND is_deleted = false;

View File

@@ -87,7 +87,7 @@ CREATE TABLE IF NOT EXISTS entities (
id UUID PRIMARY KEY DEFAULT uuidv7(),
project_id UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
name TEXT NOT NULL,
slug TEXT,
slug TEXT UNIQUE,
description TEXT,
status SMALLINT,
time_start INT,
@@ -101,6 +101,7 @@ CREATE TABLE IF NOT EXISTS wikis (
id UUID PRIMARY KEY DEFAULT uuidv7(),
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(),
@@ -114,8 +115,6 @@ CREATE TABLE IF NOT EXISTS entity_wikis (
PRIMARY KEY (entity_id, wiki_id)
);
CREATE INDEX idx_entity_wikis_project_id ON entity_wikis(project_id);
CREATE TABLE IF NOT EXISTS geometries (
id UUID PRIMARY KEY DEFAULT uuidv7(),
geo_type SMALLINT NOT NULL DEFAULT 1,
@@ -137,8 +136,6 @@ CREATE TABLE IF NOT EXISTS entity_geometries (
PRIMARY KEY (entity_id, geometry_id)
);
CREATE INDEX idx_entity_geometries_project_id ON entity_geometries(project_id);
CREATE TABLE IF NOT EXISTS commits (
id UUID PRIMARY KEY DEFAULT uuidv7(),
project_id UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,