Module project, commit, submission
All checks were successful
Build and Release / release (push) Successful in 1m15s

This commit is contained in:
2026-04-26 16:31:03 +07:00
parent ac90236022
commit 6918a100fc
60 changed files with 5957 additions and 1020 deletions

View File

@@ -0,0 +1 @@
DROP TABLE IF EXISTS commits;

View File

@@ -1,21 +1,16 @@
CREATE TABLE IF NOT EXISTS revisions (
CREATE TABLE IF NOT EXISTS commits (
id UUID PRIMARY KEY DEFAULT uuidv7(),
project_id UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
version_no INT NOT NULL,
snapshot_json JSONB NOT NULL,
snapshot_hash TEXT,
parent_id UUID REFERENCES revisions(id),
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
edit_summary TEXT,
is_deleted BOOLEAN NOT NULL DEFAULT false,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_revisions_project_history
ON revisions (project_id, version_no DESC);
CREATE INDEX idx_commits_project_history
ON commits (project_id, created_at DESC);
CREATE INDEX idx_revisions_user_history
ON revisions (user_id, created_at DESC);
CREATE INDEX idx_revisions_parent_id
ON revisions (parent_id);
CREATE INDEX idx_commits_user_history
ON commits (user_id, created_at DESC);

View File

@@ -1 +0,0 @@
DROP TABLE IF EXISTS revisions;

View File

@@ -1,24 +1,25 @@
CREATE TABLE IF NOT EXISTS submissions (
id UUID PRIMARY KEY DEFAULT uuidv7(),
project_id UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
revision_id UUID NOT NULL REFERENCES revisions(id) ON DELETE CASCADE,
submitted_by UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
submitted_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
commit_id UUID NOT NULL REFERENCES commits(id) ON DELETE CASCADE,
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
status SMALLINT NOT NULL DEFAULT 1,
reviewed_by UUID REFERENCES users(id) ON DELETE SET NULL,
reviewed_at TIMESTAMPTZ,
review_note TEXT,
is_deleted BOOLEAN NOT NULL DEFAULT false
content TEXT,
is_deleted BOOLEAN NOT NULL DEFAULT false,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_submissions_revision_id
ON submissions (revision_id);
CREATE INDEX idx_submissions_commit_id
ON submissions (commit_id);
CREATE INDEX idx_submissions_moderator_queue
ON submissions (status, submitted_at ASC);
ON submissions (status, created_at ASC);
CREATE INDEX idx_submissions_user_history
ON submissions (submitted_by, status, submitted_at DESC);
ON submissions (user_id, status, created_at DESC);
CREATE INDEX idx_submissions_project_queue
ON submissions (project_id, submitted_at DESC);
ON submissions (project_id, created_at DESC);

View File

@@ -0,0 +1 @@
DROP TABLE IF EXISTS project_members;

View File

@@ -0,0 +1,14 @@
CREATE TABLE IF NOT EXISTS project_members (
project_id UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
role SMALLINT NOT NULL DEFAULT 3, -- 1=owner, 2=editor, 3=viewer
invited_by UUID REFERENCES users(id) ON DELETE SET NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
PRIMARY KEY (project_id, user_id)
);
CREATE INDEX idx_project_members_user
ON project_members (user_id, role);
CREATE INDEX idx_project_members_project
ON project_members (project_id, role);

View File

@@ -2,8 +2,7 @@ CREATE TABLE IF NOT EXISTS projects (
id UUID PRIMARY KEY DEFAULT uuidv7(),
title TEXT NOT NULL,
description TEXT,
latest_revision_id UUID,
version_count INT NOT NULL DEFAULT 0,
latest_commit_id UUID,
project_status SMALLINT NOT NULL DEFAULT 1,
locked_by UUID,
is_deleted BOOLEAN NOT NULL DEFAULT false,
@@ -13,8 +12,8 @@ CREATE TABLE IF NOT EXISTS projects (
);
CREATE INDEX idx_projects_latest_revision_id
ON projects (latest_revision_id);
CREATE INDEX idx_projects_latest_commit_id
ON projects (latest_commit_id);
CREATE INDEX idx_projects_user_status_updated
ON projects (user_id, project_status, updated_at DESC);