forked from inventra/lazyoffice-opneclaw
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.sql
More file actions
64 lines (58 loc) · 1.96 KB
/
Copy pathinit.sql
File metadata and controls
64 lines (58 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
-- Virtual Office 資料庫初始化
-- 建立部門表
CREATE TABLE IF NOT EXISTS departments (
id SERIAL PRIMARY KEY,
name VARCHAR(50) UNIQUE NOT NULL,
label VARCHAR(100) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- 建立 agent 表
CREATE TABLE IF NOT EXISTS agents (
id VARCHAR(50) PRIMARY KEY,
name VARCHAR(100) NOT NULL,
department_id INTEGER REFERENCES departments(id),
desk_x INTEGER,
desk_y INTEGER,
status VARCHAR(20) DEFAULT 'idle',
current_task TEXT,
avatar_url TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- 建立任務表
CREATE TABLE IF NOT EXISTS tasks (
id SERIAL PRIMARY KEY,
title VARCHAR(200) NOT NULL,
description TEXT,
status VARCHAR(20) DEFAULT 'pending',
created_by VARCHAR(50) REFERENCES agents(id),
assigned_to VARCHAR(50) REFERENCES agents(id),
dispatched_by VARCHAR(50) REFERENCES agents(id),
department_id INTEGER REFERENCES departments(id),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- 建立任務流轉表
CREATE TABLE IF NOT EXISTS task_flows (
id SERIAL PRIMARY KEY,
task_id INTEGER REFERENCES tasks(id),
from_agent_id VARCHAR(50) REFERENCES agents(id),
to_agent_id VARCHAR(50) REFERENCES agents(id),
action VARCHAR(50) NOT NULL,
note TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- 插入預設部門
INSERT INTO departments (name, label) VALUES
('secretary', '秘書室'),
('engineering', '工程部'),
('design', '設計部'),
('marketing', '行銷部'),
('content', '內容部')
ON CONFLICT (name) DO NOTHING;
-- 插入預設 agents(範例)
INSERT INTO agents (id, name, department_id, desk_x, desk_y, avatar_url) VALUES
('kevin', 'Kevin小幫手', 1, 20, 30, '/assets/avatars/kevin.png'),
('alex', 'Alex', 2, 40, 50, '/assets/avatars/alex.png'),
('lena', 'Lena', 5, 60, 50, '/assets/avatars/lena.png')
ON CONFLICT (id) DO NOTHING;