cooperation/README.md
2025-01-14 20:53:10 +08:00

82 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# cooperation
协作工具
```bash
# 安装依赖(使用镜像站)
npm i --registry=https://registry.npmmirror.com
```
1. 日志格式数据, 时间戳,hash,作者,类型CURD,语句DATA
2. MD视图数据
1. 表示颜色
2. 表示用户
3. 表示转向
- [ ] 推转(将任务推到下一个工序)
- [ ] 推转等待(下一个工序处理后仍要回执的, 等待过长会造成效率低下)
- [ ] 创建项目
- [ ] 发布任务
```sql
-- 用户表
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
avatar TEXT, -- 存储头像的 URL 或路径
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 自动设置创建时间
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 自动设置更新时间
CHECK (created_at <= updated_at) -- 确保更新时间不早于创建时间
);
-- 项目表
CREATE TABLE projects (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL,
name TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 自动设置创建时间
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 自动设置更新时间
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE,
CHECK (created_at <= updated_at) -- 确保更新时间不早于创建时间
);
-- 任务表
CREATE TABLE tasks (
id INTEGER PRIMARY KEY,
project_id INTEGER NOT NULL,
name TEXT NOT NULL,
status TEXT NOT NULL DEFAULT '未开始', -- 任务状态默认未开始
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 自动设置创建时间
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 自动设置更新时间
FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE,
CHECK (created_at <= updated_at), -- 确保更新时间不早于创建时间
CHECK (status IN ('未开始', '进行中', '已完成')) -- 限制任务状态为预定义值
);
-- 问题发现 > 分析原因 > 处理方案 > 处理结果
-- 功能新增 > 分析需求 > 规划方案 > 实施结果
-- 触发器(自动设置更新时间)
CREATE TRIGGER update_users AFTER UPDATE ON users FOR EACH ROW BEGIN
UPDATE users SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id;
END;
CREATE TRIGGER update_projects AFTER UPDATE ON projects FOR EACH ROW BEGIN
UPDATE projects SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id;
END;
CREATE TRIGGER update_tasks AFTER UPDATE ON tasks FOR EACH ROW BEGIN
UPDATE tasks SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id;
END;
```
默认情况下SQLite 的外键约束是关闭的,需要在每次连接数据库时显式启用外键支持。否则,外键约束将不会生效。
```sql
PRAGMA foreign_keys = ON;
```