UPDATE: Project Module
All checks were successful
Build and Release / release (push) Successful in 1m15s
All checks were successful
Build and Release / release (push) Successful in 1m15s
This commit is contained in:
1
db/migrations/0000010_revision.down.sql
Normal file
1
db/migrations/0000010_revision.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS revisions;
|
||||
21
db/migrations/0000010_revision.up.sql
Normal file
21
db/migrations/0000010_revision.up.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
CREATE TABLE IF NOT EXISTS revisions (
|
||||
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_revisions_user_history
|
||||
ON revisions (user_id, created_at DESC);
|
||||
|
||||
CREATE INDEX idx_revisions_parent_id
|
||||
ON revisions (parent_id);
|
||||
1
db/migrations/0000011_submission.down.sql
Normal file
1
db/migrations/0000011_submission.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS submissions;
|
||||
24
db/migrations/0000011_submission.up.sql
Normal file
24
db/migrations/0000011_submission.up.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
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(),
|
||||
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
|
||||
);
|
||||
|
||||
CREATE INDEX idx_submissions_revision_id
|
||||
ON submissions (revision_id);
|
||||
|
||||
CREATE INDEX idx_submissions_moderator_queue
|
||||
ON submissions (status, submitted_at ASC);
|
||||
|
||||
CREATE INDEX idx_submissions_user_history
|
||||
ON submissions (submitted_by, status, submitted_at DESC);
|
||||
|
||||
CREATE INDEX idx_submissions_project_queue
|
||||
ON submissions (project_id, submitted_at DESC);
|
||||
@@ -4,7 +4,7 @@ CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS geometries (
|
||||
id UUID PRIMARY KEY DEFAULT uuidv7(),
|
||||
geo_type VARCHAR(50) NOT NULL DEFAULT 'id',
|
||||
geo_type SMALLINT NOT NULL DEFAULT 1,
|
||||
draw_geometry JSONB NOT NULL,
|
||||
binding JSONB,
|
||||
time_start INT,
|
||||
@@ -15,10 +15,6 @@ CREATE TABLE IF NOT EXISTS geometries (
|
||||
updated_at TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
ALTER TABLE geometries DROP CONSTRAINT IF EXISTS check_geo_type;
|
||||
ALTER TABLE geometries ADD CONSTRAINT check_geo_type
|
||||
CHECK (geo_type IN ('id', 'name', 'icon', 'variant', 'description'));
|
||||
|
||||
CREATE TABLE IF NOT EXISTS entity_geometries (
|
||||
entity_id UUID REFERENCES entities(id) ON DELETE CASCADE,
|
||||
geometry_id UUID REFERENCES geometries(id) ON DELETE CASCADE,
|
||||
|
||||
1
db/migrations/000009_project.down.sql
Normal file
1
db/migrations/000009_project.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS projects;
|
||||
26
db/migrations/000009_project.up.sql
Normal file
26
db/migrations/000009_project.up.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
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,
|
||||
project_status SMALLINT NOT NULL DEFAULT 1,
|
||||
locked_by UUID,
|
||||
is_deleted BOOLEAN NOT NULL DEFAULT false,
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
|
||||
CREATE INDEX idx_projects_latest_revision_id
|
||||
ON projects (latest_revision_id);
|
||||
|
||||
CREATE INDEX idx_projects_user_status_updated
|
||||
ON projects (user_id, project_status, updated_at DESC);
|
||||
|
||||
CREATE INDEX idx_projects_status_updated
|
||||
ON projects (project_status, updated_at DESC);
|
||||
|
||||
CREATE INDEX idx_projects_title_trgm
|
||||
ON projects USING GIN (title gin_trgm_ops);
|
||||
Reference in New Issue
Block a user