The PM panel (PmPanelPage -> iframe /pm/) needs the project-management platform served at /pm/ on the ERP domain. Source: org repo Aramesh/PM, branch feature/project-management-platform. Update via: git subtree pull --prefix=pm aramesh-pm feature/project-management-platform --squash
240 lines
9.7 KiB
Plaintext
240 lines
9.7 KiB
Plaintext
// ============================================================================
|
|
// Database Markup Language (DBML) Schema for Construction Project Management
|
|
// Website: https://dbdiagram.io / https://dbdocs.io
|
|
// ============================================================================
|
|
|
|
Project construction_pm {
|
|
database_type: 'PostgreSQL'
|
|
Note: 'پایگاهداده بومی سیستم مدیریت پروژه عمرانی و کنترل کیفیت کارگاهی'
|
|
}
|
|
|
|
// ------------------------------------------------------
|
|
// 1. Projects & Members
|
|
// ------------------------------------------------------
|
|
|
|
Table projects {
|
|
id uuid [pk, default: `gen_random_uuid()`, note: 'شناسه یکتای پروژه']
|
|
name varchar(255) [not null, note: 'نام پروژه']
|
|
description text [note: 'توضیحات و مشخصات فنی']
|
|
location varchar(255) [note: 'موقعیت جغرافیایی / کارگاه']
|
|
project_manager varchar(255) [note: 'نام مدیر پروژه / سرپرست']
|
|
status varchar(32) [not null, default: 'ACTIVE', note: 'PLANNED, ACTIVE, ON_HOLD, COMPLETED, CANCELLED']
|
|
planned_start date [note: 'تاریخ شروع برنامهریزیشده (تجمیع خودکار از تسکها)']
|
|
planned_end date [note: 'تاریخ پایان برنامهریزیشده (تجمیع خودکار از تسکها)']
|
|
actual_start date [note: 'تاریخ شروع واقعی (ثبت خودکار با آغاز کار)']
|
|
actual_end date [note: 'تاریخ پایان واقعی (ثبت خودکار در اتمام ۱۰۰٪)']
|
|
progress float [not null, default: 0.0, note: 'درصد پیشرفت وزنی کل پروژه (۰ تا ۱۰۰)']
|
|
created_at timestamptz [not null, default: `now()`]
|
|
updated_at timestamptz [not null, default: `now()`]
|
|
|
|
indexes {
|
|
name
|
|
status
|
|
}
|
|
}
|
|
|
|
Table project_members {
|
|
id uuid [pk, default: `gen_random_uuid()`]
|
|
project_id uuid [not null, note: 'پروژه مربوطه']
|
|
user_id uuid [not null, note: 'کاربر منتسب']
|
|
role varchar(32) [not null, default: 'site_engineer', note: 'project_manager, site_engineer, qc_inspector, member']
|
|
created_at timestamptz [not null, default: `now()`]
|
|
|
|
indexes {
|
|
(project_id, user_id) [unique]
|
|
}
|
|
}
|
|
|
|
Table project_assignments {
|
|
id uuid [pk, default: `gen_random_uuid()` display: 'دامنه دسترسی ناظران محدود']
|
|
user_id uuid [not null]
|
|
project_id uuid [not null]
|
|
created_at timestamptz [not null, default: `now()`]
|
|
}
|
|
|
|
// ------------------------------------------------------
|
|
// 2. Tasks & WBS Hierarchy
|
|
// ------------------------------------------------------
|
|
|
|
Table tasks {
|
|
id uuid [pk, default: `gen_random_uuid()`, note: 'شناسه یکتای وظیفه']
|
|
project_id uuid [not null, note: 'پروژه مربوطه']
|
|
parent_id uuid [null, note: 'والد در ساختار درختی WBS با عمق دلخواه']
|
|
title varchar(512) [not null, note: 'عنوان وظیفه']
|
|
description text [note: 'مشخصات، دستورکار و الزامات فنی']
|
|
status varchar(32) [not null, default: 'TODO', note: 'TODO, IN_PROGRESS, BLOCKED, COMPLETED, CANCELLED']
|
|
priority varchar(32) [not null, default: 'medium', note: 'low, medium, high, urgent']
|
|
assignee_id uuid [null, note: 'کاربر مسئول اجرا']
|
|
assignee_name varchar(255) [null, note: 'نام نمایشی مسئول']
|
|
planned_start date [null, note: 'تاریخ شروع برنامهریزیشده']
|
|
planned_end date [null, note: 'تاریخ پایان برنامهریزیشده']
|
|
actual_start date [null, note: 'شروع واقعی']
|
|
actual_end date [null, note: 'پایان واقعی']
|
|
duration int [not null, default: 1, note: 'مدت برآورد شده (روز کاری)']
|
|
progress int [not null, default: 0, note: 'درصد پیشرفت (۰ تا ۱۰۰)']
|
|
qc_status varchar(32) [not null, default: 'none', note: 'none, pre_qc_pending, pre_qc_failed, ready, exec_qc_pending, in_progress, qc_failed_rework, final_passed']
|
|
human_resources json [not null, default: '[]', note: 'نیروی انسانی: [{role, count}]']
|
|
materials json [not null, default: '[]', note: 'مصالح و تجهیزات: [{name, unit, specifications, count}]']
|
|
created_at timestamptz [not null, default: `now()`]
|
|
updated_at timestamptz [not null, default: `now()`]
|
|
|
|
indexes {
|
|
project_id
|
|
parent_id
|
|
status
|
|
}
|
|
}
|
|
|
|
// ------------------------------------------------------
|
|
// 3. Gantt Precedence & CPM Relations
|
|
// ------------------------------------------------------
|
|
|
|
Table task_relations {
|
|
id uuid [pk, default: `gen_random_uuid()`]
|
|
project_id uuid [not null, note: 'پروژه مربوطه']
|
|
from_task_id uuid [not null, note: 'فعالیت پیشنیاز (Predecessor)']
|
|
to_task_id uuid [not null, note: 'فعالیت پسنیاز / وابسته (Successor)']
|
|
relation_type varchar(8) [not null, default: 'FS', note: 'FS, SS, FF, SF']
|
|
lag_days int [not null, default: 0, note: 'تاخیر یا تقدم مجاز (روز)']
|
|
created_at timestamptz [not null, default: `now()`]
|
|
|
|
indexes {
|
|
(from_task_id, to_task_id) [unique]
|
|
project_id
|
|
}
|
|
}
|
|
|
|
// ------------------------------------------------------
|
|
// 4. Quality Control & Inspection
|
|
// ------------------------------------------------------
|
|
|
|
Table qc_templates {
|
|
id uuid [pk, default: `gen_random_uuid()`]
|
|
name varchar(255) [not null, note: 'نام چکلیست الگو']
|
|
activity_type varchar(64) [note: 'نوع فعالیت کارگاهی']
|
|
description text
|
|
created_at timestamptz [not null, default: `now()`]
|
|
|
|
indexes {
|
|
activity_type
|
|
}
|
|
}
|
|
|
|
Table qc_questions {
|
|
id uuid [pk, default: `gen_random_uuid()`]
|
|
template_id uuid [not null]
|
|
phase varchar(16) [not null, note: 'مرحله بازرسی: pre, during, after']
|
|
text varchar(512) [not null, note: 'متن ضابطه یا سؤال کنترلی']
|
|
sort_order int [not null, default: 0]
|
|
required boolean [not null, default: true]
|
|
|
|
indexes {
|
|
template_id
|
|
}
|
|
}
|
|
|
|
Table task_qc_definitions {
|
|
id uuid [pk, default: `gen_random_uuid()`]
|
|
task_id uuid [not null, note: 'تسک مربوطه']
|
|
name varchar(255) [not null, default: '']
|
|
source_template_id uuid [null, note: 'منشأ الگو (جهت ردیابی)']
|
|
created_at timestamptz [not null, default: `now()`]
|
|
updated_at timestamptz [not null, default: `now()`]
|
|
|
|
indexes {
|
|
task_id
|
|
}
|
|
}
|
|
|
|
Table task_qc_questions {
|
|
id uuid [pk, default: `gen_random_uuid()`]
|
|
definition_id uuid [not null]
|
|
phase varchar(16) [not null, note: 'مرحله بازرسی: pre, during, after']
|
|
text varchar(512) [not null]
|
|
sort_order int [not null, default: 0]
|
|
required boolean [not null, default: true]
|
|
|
|
indexes {
|
|
definition_id
|
|
}
|
|
}
|
|
|
|
Table task_qc_results {
|
|
id uuid [pk, default: `gen_random_uuid()` note: 'ثبت پیوسته تاریخچه ارزیابی بازرسان (Append-Only)']
|
|
question_id uuid [not null]
|
|
answer varchar(16) [not null, note: 'pass, fail, na']
|
|
comment text [note: 'یادداشت یا علت رد']
|
|
evaluated_by varchar(255) [not null, default: '', note: 'نام بازرس']
|
|
evaluated_at timestamptz [not null, default: `now()`]
|
|
|
|
indexes {
|
|
question_id
|
|
}
|
|
}
|
|
|
|
Table defects {
|
|
id uuid [pk, default: `gen_random_uuid()`, note: 'عدم انطباق یا عیب کارگاهی']
|
|
task_id uuid [not null, note: 'تسک مربوطه']
|
|
question_id uuid [null, note: 'سؤال QC منجر به عیب (اختیاری)']
|
|
title varchar(512) [not null, note: 'عنوان عدم انطباق']
|
|
description text [note: 'شرح ایراد مشاهدهشده']
|
|
severity varchar(16) [not null, default: 'medium', note: 'minor, medium, major, critical']
|
|
status varchar(16) [not null, default: 'open', note: 'open, in_progress, resolved']
|
|
corrective_action text [note: 'دستور اقدام اصلاحی']
|
|
resolution_notes text [note: 'گزارش رفع عیب']
|
|
photo_path varchar(512) [null, note: 'مسیر تصویر پیوست عیب']
|
|
created_at timestamptz [not null, default: `now()`]
|
|
resolved_at timestamptz [null, note: 'زمان تایید رفع عیب']
|
|
|
|
indexes {
|
|
task_id
|
|
}
|
|
}
|
|
|
|
// ------------------------------------------------------
|
|
// 5. Users & Authentication
|
|
// ------------------------------------------------------
|
|
|
|
Table pm_users {
|
|
id uuid [pk, default: `gen_random_uuid()`]
|
|
username varchar(64) [unique, not null]
|
|
password_hash varchar(255) [not null]
|
|
display_name varchar(255) [not null, default: '']
|
|
role varchar(32) [not null, default: 'project_manager', note: 'project_manager, project_supervisor']
|
|
created_at timestamptz [not null, default: `now()`]
|
|
|
|
indexes {
|
|
username
|
|
}
|
|
}
|
|
|
|
// ------------------------------------------------------
|
|
// Foreign Key Relationships
|
|
// ------------------------------------------------------
|
|
|
|
Ref: project_members.project_id > projects.id [delete: cascade]
|
|
Ref: project_members.user_id > pm_users.id [delete: cascade]
|
|
|
|
Ref: project_assignments.project_id > projects.id [delete: cascade]
|
|
Ref: project_assignments.user_id > pm_users.id [delete: cascade]
|
|
|
|
Ref: tasks.project_id > projects.id [delete: cascade]
|
|
Ref: tasks.parent_id > tasks.id [delete: cascade]
|
|
Ref: tasks.assignee_id > pm_users.id [delete: set null]
|
|
|
|
Ref: task_relations.project_id > projects.id [delete: cascade]
|
|
Ref: task_relations.from_task_id > tasks.id [delete: cascade]
|
|
Ref: task_relations.to_task_id > tasks.id [delete: cascade]
|
|
|
|
Ref: qc_questions.template_id > qc_templates.id [delete: cascade]
|
|
|
|
Ref: task_qc_definitions.task_id > tasks.id [delete: cascade]
|
|
Ref: task_qc_definitions.source_template_id > qc_templates.id [delete: set null]
|
|
|
|
Ref: task_qc_questions.definition_id > task_qc_definitions.id [delete: cascade]
|
|
|
|
Ref: task_qc_results.question_id > task_qc_questions.id [delete: cascade]
|
|
|
|
Ref: defects.task_id > tasks.id [delete: cascade]
|
|
Ref: defects.question_id > task_qc_questions.id [delete: set null]
|