From 2eb858a7437d6ec369999eb35b897d735c307abe Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 18 Dec 2025 07:08:52 +0000 Subject: [PATCH] =?UTF-8?q?chat=E5=89=8D=E7=AB=AF=E8=81=94=E8=B0=83?= =?UTF-8?q?=E6=8C=87=E5=8D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/agents/diagnosis_agent.py | 2 +- backend/app/routers/ai.py | 6 +- backend/app/services/llm.py | 6 +- backend/docs/前端聊天联调指南.md | 247 +++ backend/dump.sql | 2193 ++++++++++++++++++++++ backend/hadoop_fault.dump | Bin 0 -> 75995 bytes backend/insert_dump.sql | 0 backend/insert_summary.txt | 0 backend/tests/test_llm.py | 43 + insert_dump.sql | 2167 +++++++++++++++++++++ 10 files changed, 4658 insertions(+), 6 deletions(-) create mode 100644 backend/docs/前端聊天联调指南.md create mode 100644 backend/dump.sql create mode 100644 backend/hadoop_fault.dump create mode 100644 backend/insert_dump.sql create mode 100644 backend/insert_summary.txt create mode 100644 backend/tests/test_llm.py create mode 100644 insert_dump.sql diff --git a/backend/app/agents/diagnosis_agent.py b/backend/app/agents/diagnosis_agent.py index 4e010bd..1b999e6 100644 --- a/backend/app/agents/diagnosis_agent.py +++ b/backend/app/agents/diagnosis_agent.py @@ -31,7 +31,7 @@ async def run_diagnose_and_repair(db: AsyncSession, operator: str, context: Dict residual_risk = "medium" for step in range(max_steps): - resp = llm.chat(messages, tools=tools, stream=False) + resp = await llm.chat(messages, tools=tools, stream=False) choice = (resp.get("choices") or [{}])[0] msg = choice.get("message", {}) tool_calls = msg.get("tool_calls") or [] diff --git a/backend/app/routers/ai.py b/backend/app/routers/ai.py index b9c5e1f..50c2ddb 100644 --- a/backend/app/routers/ai.py +++ b/backend/app/routers/ai.py @@ -58,12 +58,14 @@ async def diagnose_repair(req: DiagnoseRepairReq, user=Depends(get_current_user) async def ai_chat(req: ChatReq, user=Depends(get_current_user)): try: llm = LLMClient() - resp = llm.chat(req.messages, tools=None, stream=False) + resp = await llm.chat(req.messages, tools=None, stream=False) choices = resp.get("choices") or [] if not choices: raise HTTPException(status_code=502, detail="llm_unavailable") msg = choices[0].get("message") or {} - return {"reply": msg.get("content") or ""} + reply = msg.get("content") or "" + reasoning = msg.get("reasoning_content") or "" + return {"reply": reply, "reasoning": reasoning} except HTTPException: raise except Exception: diff --git a/backend/app/services/llm.py b/backend/app/services/llm.py index aa922cd..0c24f65 100644 --- a/backend/app/services/llm.py +++ b/backend/app/services/llm.py @@ -57,7 +57,7 @@ class LLMClient: "Content-Type": "application/json", } - def chat(self, messages: List[Dict[str, Any]], tools: Optional[List[Dict[str, Any]]] = None, stream: bool = False) -> Dict[str, Any]: + async def chat(self, messages: List[Dict[str, Any]], tools: Optional[List[Dict[str, Any]]] = None, stream: bool = False) -> Dict[str, Any]: if self.simulate or httpx is None: return { "choices": [ @@ -74,7 +74,7 @@ class LLMClient: if tools: payload["tools"] = tools payload["tool_choice"] = "auto" - with httpx.Client(timeout=self.timeout) as client: - resp = client.post(self.endpoint, headers=self._headers(), json=payload) + async with httpx.AsyncClient(timeout=self.timeout) as client: + resp = await client.post(self.endpoint, headers=self._headers(), json=payload) resp.raise_for_status() return resp.json() diff --git a/backend/docs/前端聊天联调指南.md b/backend/docs/前端聊天联调指南.md new file mode 100644 index 0000000..d82de03 --- /dev/null +++ b/backend/docs/前端聊天联调指南.md @@ -0,0 +1,247 @@ +# 前端聊天联调指南 + +本指南用于对接后端聊天接口,包括非流式与流式两种模式,涵盖鉴权、请求/响应契约、前端示例代码以及常见问题。 + +## 概述 +- 后端服务:FastAPI +- 核心接口:`POST /api/v1/ai/chat`(非流式) +- 鉴权:`Authorization: Bearer ` +- 模型:DeepSeek R1(支持推理内容 `reasoning_content`) +- 相关代码位置: + - 路由:`backend/app/routers/ai.py:57` + - 返回结构:`backend/app/routers/ai.py:64-67` + - LLM 客户端:`backend/app/services/llm.py:44` + - CORS 中间件:`backend/app/main.py:8-14` + - 鉴权依赖:`backend/app/deps/auth.py:9` + - 登录接口:`backend/app/routers/auth.py:25` + - 工具调用(诊断):`backend/app/agents/diagnosis_agent.py:33-54` + +## 鉴权与获取 Token +- 登录接口:`POST /api/v1/user/login` +- 成功返回包含 `token` 字段 +- 所有聊天请求需携带 Header:`Authorization: Bearer ` + +示例(fetch): +```ts +async function login(username: string, password: string) { + const resp = await fetch(`${API_BASE}/api/v1/user/login`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ username, password }), + }); + const data = await resp.json(); + if (!resp.ok) throw new Error(data?.detail ?? "login_failed"); + return data.token as string; +} +``` + +## 接口契约(非流式) +- URL:`POST /api/v1/ai/chat` +- Header:`Authorization: Bearer `,`Content-Type: application/json` +- Body: +```json +{ + "messages": [ + { "role": "system", "content": "你是Hadoop运维诊断专家..." }, + { "role": "user", "content": "请分析 Yarn 任务失败原因" } + ] +} +``` +- 响应: +```json +{ "reply": "回答内容", "reasoning": "推理过程(可能为空)" } +``` + +类型建议: +```ts +type ChatRole = "system" | "user" | "assistant"; +type ChatMessage = { role: ChatRole; content: string }; +type ChatRequest = { messages: ChatMessage[] }; +type ChatResponse = { reply: string; reasoning?: string }; +``` + +请求示例(axios): +```ts +import axios from "axios"; + +async function chat(messages: ChatMessage[], token: string): Promise { + const resp = await axios.post( + `${API_BASE}/api/v1/ai/chat`, + { messages }, + { + headers: { + "Authorization": `Bearer ${token}`, + "Content-Type": "application/json", + }, + timeout: 30000, + } + ); + return resp.data; +} +``` + +请求示例(fetch): +```ts +async function chatFetch(messages: ChatMessage[], token: string): Promise { + const resp = await fetch(`${API_BASE}/api/v1/ai/chat`, { + method: "POST", + headers: { + "Authorization": `Bearer ${token}`, + "Content-Type": "application/json", + "Accept": "application/json", + }, + body: JSON.stringify({ messages }), + }); + if (!resp.ok) throw new Error(`Chat failed: ${resp.status}`); + return await resp.json(); +} +``` + +## 流式对接指南(前端实现约定) +后端当前为非流式响应。为便于先行集成,前端可按以下约定实现流式客户端;当后端提供流式端点后即可直接联通。 + +两种常见流式方案: +- SSE(Server-Sent Events) + - 响应头:`Content-Type: text/event-stream` + - 行格式:`data: `;完成标记:`data: [DONE]` + - 事件内容(参考 OpenAI/DeepSeek): + - 增量文本:`{"choices":[{"delta":{"content":"..."}}]}` + - 增量推理:`{"choices":[{"delta":{"reasoning_content":"..."}}]}` + - 完成:`{"choices":[{"finish_reason":"stop"}]}` + - 注意:原生 `EventSource` 不支持自定义 Header(鉴权)。可用 polyfill 支持 Header 或后端改用查询参数传 token。 +- Fetch 可读流(ReadableStream) + - 响应:分块传输(chunked),逐行 NDJSON;完成行:`[DONE]` + - 支持自定义 Header,适配当前鉴权方式(推荐) + +SSE 方案(使用支持 Header 的 polyfill): +```ts +type StreamDelta = { content?: string; reasoning_content?: string }; + +function startChatSSE( + messages: ChatMessage[], + token: string, + onDelta: (d: StreamDelta) => void, + onDone: () => void, + onError: (e: any) => void +) { + const url = `${API_BASE}/api/v1/ai/chat/stream`; + const es = new EventSourcePolyfill(url, { + headers: { Authorization: `Bearer ${token}` }, + payload: JSON.stringify({ messages, stream: true }), + method: "POST", + }); + + es.onmessage = (evt) => { + const t = evt.data; + if (t === "[DONE]") { onDone(); es.close(); return; } + try { + const j = JSON.parse(t); + const delta = j?.choices?.[0]?.delta || {}; + onDelta({ content: delta.content, reasoning_content: delta.reasoning_content }); + } catch (e) { onError(e); } + }; + es.onerror = (e) => { onError(e); es.close(); }; + return () => es.close(); +} +``` + +Fetch 可读流方案(推荐,支持 Header): +```ts +async function startChatStream( + messages: ChatMessage[], + token: string, + onDelta: (d: StreamDelta) => void, + onDone: () => void +) { + const resp = await fetch(`${API_BASE}/api/v1/ai/chat?stream=true`, { + method: "POST", + headers: { + "Authorization": `Bearer ${token}`, + "Content-Type": "application/json", + "Accept": "application/json", + }, + body: JSON.stringify({ messages }), + }); + if (!resp.body) throw new Error("No stream body"); + + const reader = resp.body.getReader(); + const decoder = new TextDecoder("utf-8"); + let buffer = ""; + + while (true) { + const { value, done } = await reader.read(); + if (done) break; + buffer += decoder.decode(value, { stream: true }); + + let idx; + while ((idx = buffer.indexOf("\n")) >= 0) { + const line = buffer.slice(0, idx).trim(); + buffer = buffer.slice(idx + 1); + if (!line) continue; + if (line === "[DONE]") { onDone(); return; } + try { + const j = JSON.parse(line); + const delta = j?.choices?.[0]?.delta || {}; + onDelta({ content: delta.content, reasoning_content: delta.reasoning_content }); + } catch { /* 忽略半包或非 JSON 行 */ } + } + } + onDone(); +} +``` + +## React 组件集成建议 +- 状态管理: + - `messages: ChatMessage[]` 会话消息 + - `partialReply: string` 流式拼接的回答 + - `partialReasoning: string` 流式拼接的推理 + - `loading: boolean` 是否正在生成 + - 可选 `AbortController` 用于取消 +- 交互流程: + - 用户输入后 `messages.push({ role: "user", content: input })` + - 触发流式接口,增量拼接 `partialReply` 与 `partialReasoning` + - 完成后将 `partialReply` 作为 `assistant` 消息加入 `messages` 并清空临时态 + - 推理内容建议以折叠/切换方式显示,避免干扰主对话 + +## 错误处理与重试策略 +- 401 未鉴权:跳转登录或刷新 token(参考 `backend/app/deps/auth.py:9-31`) +- 403 用户未激活:提示管理员处理 +- 502 模型不可用:提示“模型服务不可用”,支持重试 +- 500 服务错误:toast 提示,记录时间戳便于排查 +- 超时/网络中断:提供“停止生成/重试”按钮,保留已生成内容 + +## 提示词注入建议 +在会话首条注入系统提示词,以提升回答质量: +```ts +const systemPrompt: ChatMessage = { + role: "system", + content: "你是Hadoop运维诊断专家。你需要根据系统日志进行分析,输出中文,优先给出根因、影响范围与修复建议。" +}; +const msgs: ChatMessage[] = [systemPrompt, { role: "user", content: "请分析 Yarn 应用失败原因" }]; +``` + +## 本地联调自检 +- 登录获取 token +- 使用 curl 验证非流式接口: +``` +curl -X POST 'http://localhost:8000/api/v1/ai/chat' \ + -H 'Authorization: Bearer ' \ + -H 'Content-Type: application/json' \ + -d '{"messages":[{"role":"user","content":"你好"}]}' +``` +- 前端设置 `API_BASE` 指向后端地址,确保浏览器端 CORS 正常(后端已允许,参见 `backend/app/main.py:8-14`) + +## 常见问题 +- 原生 `EventSource` 如何携带 token? + - 原生不支持 Header,可改用 query 传 token(需后端支持)或使用支持 Header 的 SSE polyfill;更推荐 Fetch 可读流。 +- `reasoning` 为空怎么办? + - DeepSeek R1 某些回答可能不返回推理,前端需兼容空值并在 UI 中隐藏推理区域。 +- 如何展示工具调用过程? + - 参考 `backend/app/agents/diagnosis_agent.py:33-54` 的返回结构,前端可在“诊断/修复”场景增加步骤视图。 + +## 配置项建议 +- `API_BASE`:后端基础地址(如 `http://localhost:8000`) +- `STREAM_ENABLED`:是否启用流式(后端未提供流式端点前为 `false`) +- `TIMEOUT_MS`:请求超时时间(建议 30s) +- UI:是否显示推理内容(默认折叠) + diff --git a/backend/dump.sql b/backend/dump.sql new file mode 100644 index 0000000..4803f45 --- /dev/null +++ b/backend/dump.sql @@ -0,0 +1,2193 @@ +-- +-- PostgreSQL database dump +-- + +\restrict x3vbKb2vAIlctC0uebdrXag55BFVsJBRQxqhKA1MdoFQjC3OJ9m4YZLeFNLKBRA + +-- Dumped from database version 15.15 (Debian 15.15-1.pgdg13+1) +-- Dumped by pg_dump version 15.15 (Debian 15.15-1.pgdg13+1) + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: app_configurations; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.app_configurations ( + id bigint NOT NULL, + config_type character varying(20) NOT NULL, + config_key character varying(100) NOT NULL, + config_value jsonb NOT NULL, + description character varying(500), + is_enabled boolean DEFAULT true NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT app_config_type_chk CHECK (((config_type)::text = ANY ((ARRAY['system'::character varying, 'alert_rule'::character varying, 'notification'::character varying, 'llm'::character varying])::text[]))) +); + + +ALTER TABLE public.app_configurations OWNER TO postgres; + +-- +-- Name: TABLE app_configurations; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.app_configurations IS '应用统一配置表'; + + +-- +-- Name: COLUMN app_configurations.id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.app_configurations.id IS '主键ID'; + + +-- +-- Name: COLUMN app_configurations.config_type; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.app_configurations.config_type IS '配置类型(system/alert_rule/notification/llm)'; + + +-- +-- Name: COLUMN app_configurations.config_key; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.app_configurations.config_key IS '配置键'; + + +-- +-- Name: COLUMN app_configurations.config_value; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.app_configurations.config_value IS '配置值(JSONB)'; + + +-- +-- Name: COLUMN app_configurations.description; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.app_configurations.description IS '配置描述'; + + +-- +-- Name: COLUMN app_configurations.is_enabled; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.app_configurations.is_enabled IS '是否启用'; + + +-- +-- Name: COLUMN app_configurations.created_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.app_configurations.created_at IS '创建时间'; + + +-- +-- Name: COLUMN app_configurations.updated_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.app_configurations.updated_at IS '更新时间'; + + +-- +-- Name: app_configurations_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +ALTER TABLE public.app_configurations ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME public.app_configurations_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: audit_logs; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.audit_logs ( + id bigint NOT NULL, + user_id bigint, + cluster_id bigint, + role_id bigint, + username character varying(50) NOT NULL, + action character varying(100) NOT NULL, + resource_type character varying(50) NOT NULL, + resource_id character varying(100), + ip_address inet NOT NULL, + request_data jsonb, + response_status integer, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE public.audit_logs OWNER TO postgres; + +-- +-- Name: TABLE audit_logs; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.audit_logs IS '操作审计表'; + + +-- +-- Name: COLUMN audit_logs.id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.audit_logs.id IS '主键ID'; + + +-- +-- Name: COLUMN audit_logs.user_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.audit_logs.user_id IS '用户ID'; + + +-- +-- Name: COLUMN audit_logs.cluster_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.audit_logs.cluster_id IS '集群ID'; + + +-- +-- Name: COLUMN audit_logs.role_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.audit_logs.role_id IS '角色ID'; + + +-- +-- Name: COLUMN audit_logs.username; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.audit_logs.username IS '用户名'; + + +-- +-- Name: COLUMN audit_logs.action; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.audit_logs.action IS '操作动作'; + + +-- +-- Name: COLUMN audit_logs.resource_type; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.audit_logs.resource_type IS '资源类型'; + + +-- +-- Name: COLUMN audit_logs.resource_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.audit_logs.resource_id IS '资源ID'; + + +-- +-- Name: COLUMN audit_logs.ip_address; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.audit_logs.ip_address IS '请求来源IP(INET, 兼容IPv4/IPv6)'; + + +-- +-- Name: COLUMN audit_logs.request_data; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.audit_logs.request_data IS '请求数据(JSONB)'; + + +-- +-- Name: COLUMN audit_logs.response_status; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.audit_logs.response_status IS '响应状态码'; + + +-- +-- Name: COLUMN audit_logs.created_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.audit_logs.created_at IS '创建时间'; + + +-- +-- Name: audit_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +ALTER TABLE public.audit_logs ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME public.audit_logs_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: clusters; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.clusters ( + id bigint NOT NULL, + uuid uuid NOT NULL, + name character varying(100) NOT NULL, + type character varying(50) NOT NULL, + node_count integer DEFAULT 0 NOT NULL, + health_status character varying(20) DEFAULT 'unknown'::character varying NOT NULL, + description text, + config_info jsonb, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT clusters_health_status_chk CHECK (((health_status)::text = ANY ((ARRAY['healthy'::character varying, 'warning'::character varying, 'error'::character varying, 'unknown'::character varying])::text[]))) +); + + +ALTER TABLE public.clusters OWNER TO postgres; + +-- +-- Name: TABLE clusters; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.clusters IS '集群信息表'; + + +-- +-- Name: COLUMN clusters.id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.clusters.id IS '主键ID'; + + +-- +-- Name: COLUMN clusters.uuid; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.clusters.uuid IS '集群唯一标识(UUID)'; + + +-- +-- Name: COLUMN clusters.name; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.clusters.name IS '集群名称'; + + +-- +-- Name: COLUMN clusters.type; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.clusters.type IS '集群类型'; + + +-- +-- Name: COLUMN clusters.node_count; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.clusters.node_count IS '集群节点数量'; + + +-- +-- Name: COLUMN clusters.health_status; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.clusters.health_status IS '集群健康状态(healthy/warning/error/unknown)'; + + +-- +-- Name: COLUMN clusters.description; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.clusters.description IS '集群描述'; + + +-- +-- Name: COLUMN clusters.config_info; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.clusters.config_info IS '集群配置信息(JSONB)'; + + +-- +-- Name: COLUMN clusters.created_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.clusters.created_at IS '创建时间'; + + +-- +-- Name: COLUMN clusters.updated_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.clusters.updated_at IS '更新时间'; + + +-- +-- Name: clusters_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +ALTER TABLE public.clusters ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME public.clusters_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: exec_logs; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.exec_logs ( + id bigint NOT NULL, + exec_id character varying(32) NOT NULL, + fault_id character varying(32) NOT NULL, + command_type character varying(50) NOT NULL, + script_path character varying(255), + command_content text NOT NULL, + target_nodes jsonb, + risk_level character varying(20) DEFAULT 'medium'::character varying NOT NULL, + execution_status character varying(20) DEFAULT 'pending'::character varying NOT NULL, + start_time timestamp with time zone, + end_time timestamp with time zone, + duration integer, + stdout_log text, + stderr_log text, + exit_code integer, + operator character varying(50) DEFAULT 'system'::character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT exec_logs_duration_chk CHECK (((duration IS NULL) OR (duration >= 0))), + CONSTRAINT exec_logs_risk_chk CHECK (((risk_level)::text = ANY ((ARRAY['low'::character varying, 'medium'::character varying, 'high'::character varying])::text[]))), + CONSTRAINT exec_logs_status_chk CHECK (((execution_status)::text = ANY ((ARRAY['pending'::character varying, 'running'::character varying, 'success'::character varying, 'failed'::character varying, 'timeout'::character varying])::text[]))) +); + + +ALTER TABLE public.exec_logs OWNER TO postgres; + +-- +-- Name: TABLE exec_logs; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.exec_logs IS '执行日志表'; + + +-- +-- Name: COLUMN exec_logs.id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.id IS '主键ID'; + + +-- +-- Name: COLUMN exec_logs.exec_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.exec_id IS '执行唯一标识'; + + +-- +-- Name: COLUMN exec_logs.fault_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.fault_id IS '关联故障标识(无外键)'; + + +-- +-- Name: COLUMN exec_logs.command_type; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.command_type IS '命令类型'; + + +-- +-- Name: COLUMN exec_logs.script_path; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.script_path IS '脚本路径'; + + +-- +-- Name: COLUMN exec_logs.command_content; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.command_content IS '执行的命令内容'; + + +-- +-- Name: COLUMN exec_logs.target_nodes; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.target_nodes IS '目标执行节点(JSONB)'; + + +-- +-- Name: COLUMN exec_logs.risk_level; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.risk_level IS '风险级别(low/medium/high)'; + + +-- +-- Name: COLUMN exec_logs.execution_status; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.execution_status IS '执行状态(pending/running/success/failed/timeout)'; + + +-- +-- Name: COLUMN exec_logs.start_time; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.start_time IS '开始执行时间'; + + +-- +-- Name: COLUMN exec_logs.end_time; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.end_time IS '结束执行时间'; + + +-- +-- Name: COLUMN exec_logs.duration; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.duration IS '执行时长(秒)'; + + +-- +-- Name: COLUMN exec_logs.stdout_log; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.stdout_log IS '标准输出日志'; + + +-- +-- Name: COLUMN exec_logs.stderr_log; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.stderr_log IS '错误输出日志'; + + +-- +-- Name: COLUMN exec_logs.exit_code; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.exit_code IS '退出码'; + + +-- +-- Name: COLUMN exec_logs.operator; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.operator IS '操作人'; + + +-- +-- Name: COLUMN exec_logs.created_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.created_at IS '创建时间'; + + +-- +-- Name: COLUMN exec_logs.updated_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.exec_logs.updated_at IS '更新时间'; + + +-- +-- Name: exec_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +ALTER TABLE public.exec_logs ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME public.exec_logs_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: nodes; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.nodes ( + id bigint NOT NULL, + uuid uuid NOT NULL, + cluster_id bigint NOT NULL, + hostname character varying(100) NOT NULL, + ip_address inet NOT NULL, + status character varying(20) DEFAULT 'unknown'::character varying NOT NULL, + cpu_usage numeric(5,2), + memory_usage numeric(5,2), + disk_usage numeric(5,2), + last_heartbeat timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT nodes_cpu_chk CHECK (((cpu_usage IS NULL) OR ((cpu_usage >= (0)::numeric) AND (cpu_usage <= (100)::numeric)))), + CONSTRAINT nodes_disk_chk CHECK (((disk_usage IS NULL) OR ((disk_usage >= (0)::numeric) AND (disk_usage <= (100)::numeric)))), + CONSTRAINT nodes_mem_chk CHECK (((memory_usage IS NULL) OR ((memory_usage >= (0)::numeric) AND (memory_usage <= (100)::numeric)))), + CONSTRAINT nodes_status_chk CHECK (((status)::text = ANY ((ARRAY['healthy'::character varying, 'unhealthy'::character varying, 'warning'::character varying, 'unknown'::character varying])::text[]))) +); + + +ALTER TABLE public.nodes OWNER TO postgres; + +-- +-- Name: TABLE nodes; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.nodes IS '节点信息表'; + + +-- +-- Name: COLUMN nodes.id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.nodes.id IS '主键ID'; + + +-- +-- Name: COLUMN nodes.uuid; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.nodes.uuid IS '节点唯一标识(UUID)'; + + +-- +-- Name: COLUMN nodes.cluster_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.nodes.cluster_id IS '所属集群ID'; + + +-- +-- Name: COLUMN nodes.hostname; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.nodes.hostname IS '节点主机名'; + + +-- +-- Name: COLUMN nodes.ip_address; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.nodes.ip_address IS '节点IP地址(INET, 兼容IPv4/IPv6)'; + + +-- +-- Name: COLUMN nodes.status; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.nodes.status IS '节点健康状态(healthy/unhealthy/warning/unknown)'; + + +-- +-- Name: COLUMN nodes.cpu_usage; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.nodes.cpu_usage IS 'CPU使用率(%)'; + + +-- +-- Name: COLUMN nodes.memory_usage; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.nodes.memory_usage IS '内存使用率(%)'; + + +-- +-- Name: COLUMN nodes.disk_usage; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.nodes.disk_usage IS '磁盘使用率(%)'; + + +-- +-- Name: COLUMN nodes.last_heartbeat; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.nodes.last_heartbeat IS '最后心跳时间'; + + +-- +-- Name: COLUMN nodes.created_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.nodes.created_at IS '创建时间'; + + +-- +-- Name: COLUMN nodes.updated_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.nodes.updated_at IS '更新时间'; + + +-- +-- Name: nodes_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +ALTER TABLE public.nodes ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME public.nodes_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: permissions; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.permissions ( + id bigint NOT NULL, + permission_name character varying(100) NOT NULL, + permission_key character varying(100) NOT NULL, + description character varying(255), + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE public.permissions OWNER TO postgres; + +-- +-- Name: TABLE permissions; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.permissions IS '权限表'; + + +-- +-- Name: COLUMN permissions.id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.permissions.id IS '主键ID'; + + +-- +-- Name: COLUMN permissions.permission_name; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.permissions.permission_name IS '权限名称'; + + +-- +-- Name: COLUMN permissions.permission_key; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.permissions.permission_key IS '权限唯一标识'; + + +-- +-- Name: COLUMN permissions.description; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.permissions.description IS '权限描述'; + + +-- +-- Name: COLUMN permissions.created_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.permissions.created_at IS '创建时间'; + + +-- +-- Name: permissions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +ALTER TABLE public.permissions ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME public.permissions_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: repair_templates; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.repair_templates ( + id bigint NOT NULL, + template_name character varying(100) NOT NULL, + fault_type character varying(50) NOT NULL, + script_content text NOT NULL, + risk_level character varying(20) DEFAULT 'medium'::character varying NOT NULL, + description text, + parameters jsonb, + created_by character varying(50), + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT repair_templates_risk_chk CHECK (((risk_level)::text = ANY ((ARRAY['low'::character varying, 'medium'::character varying, 'high'::character varying])::text[]))) +); + + +ALTER TABLE public.repair_templates OWNER TO postgres; + +-- +-- Name: TABLE repair_templates; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.repair_templates IS '修复脚本模板表'; + + +-- +-- Name: COLUMN repair_templates.id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.repair_templates.id IS '主键ID'; + + +-- +-- Name: COLUMN repair_templates.template_name; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.repair_templates.template_name IS '模板名称'; + + +-- +-- Name: COLUMN repair_templates.fault_type; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.repair_templates.fault_type IS '适用故障类型'; + + +-- +-- Name: COLUMN repair_templates.script_content; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.repair_templates.script_content IS '脚本内容'; + + +-- +-- Name: COLUMN repair_templates.risk_level; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.repair_templates.risk_level IS '风险级别(low/medium/high)'; + + +-- +-- Name: COLUMN repair_templates.description; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.repair_templates.description IS '模板描述'; + + +-- +-- Name: COLUMN repair_templates.parameters; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.repair_templates.parameters IS '模板参数定义(JSONB)'; + + +-- +-- Name: COLUMN repair_templates.created_by; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.repair_templates.created_by IS '创建人'; + + +-- +-- Name: COLUMN repair_templates.created_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.repair_templates.created_at IS '创建时间'; + + +-- +-- Name: COLUMN repair_templates.updated_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.repair_templates.updated_at IS '更新时间'; + + +-- +-- Name: repair_templates_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +ALTER TABLE public.repair_templates ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME public.repair_templates_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: role_permission_mapping; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.role_permission_mapping ( + role_id bigint NOT NULL, + permission_id bigint NOT NULL +); + + +ALTER TABLE public.role_permission_mapping OWNER TO postgres; + +-- +-- Name: TABLE role_permission_mapping; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.role_permission_mapping IS '角色-权限映射表'; + + +-- +-- Name: COLUMN role_permission_mapping.role_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.role_permission_mapping.role_id IS '角色ID'; + + +-- +-- Name: COLUMN role_permission_mapping.permission_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.role_permission_mapping.permission_id IS '权限ID'; + + +-- +-- Name: roles; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.roles ( + id bigint NOT NULL, + role_name character varying(50) NOT NULL, + role_key character varying(50) NOT NULL, + description character varying(255), + is_system_role boolean DEFAULT false NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE public.roles OWNER TO postgres; + +-- +-- Name: TABLE roles; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.roles IS '角色表'; + + +-- +-- Name: COLUMN roles.id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.roles.id IS '主键ID'; + + +-- +-- Name: COLUMN roles.role_name; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.roles.role_name IS '角色名称'; + + +-- +-- Name: COLUMN roles.role_key; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.roles.role_key IS '角色唯一标识'; + + +-- +-- Name: COLUMN roles.description; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.roles.description IS '角色描述'; + + +-- +-- Name: COLUMN roles.is_system_role; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.roles.is_system_role IS '是否为系统内置角色'; + + +-- +-- Name: COLUMN roles.created_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.roles.created_at IS '创建时间'; + + +-- +-- Name: COLUMN roles.updated_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.roles.updated_at IS '更新时间'; + + +-- +-- Name: roles_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +ALTER TABLE public.roles ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME public.roles_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: system_logs; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.system_logs ( + id bigint NOT NULL, + log_id character varying(32) NOT NULL, + fault_id character varying(32), + cluster_id bigint, + "timestamp" timestamp with time zone NOT NULL, + host character varying(100) NOT NULL, + service character varying(50) NOT NULL, + source character varying(50), + log_level character varying(10) NOT NULL, + message text NOT NULL, + exception text, + raw_log text, + processed boolean DEFAULT false NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT system_logs_level_chk CHECK (((log_level)::text = ANY ((ARRAY['DEBUG'::character varying, 'INFO'::character varying, 'WARN'::character varying, 'ERROR'::character varying, 'FATAL'::character varying])::text[]))) +); + + +ALTER TABLE public.system_logs OWNER TO postgres; + +-- +-- Name: TABLE system_logs; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.system_logs IS '系统日志表'; + + +-- +-- Name: COLUMN system_logs.id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.id IS '主键ID'; + + +-- +-- Name: COLUMN system_logs.log_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.log_id IS '日志唯一标识'; + + +-- +-- Name: COLUMN system_logs.fault_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.fault_id IS '关联故障标识(无外键)'; + + +-- +-- Name: COLUMN system_logs.cluster_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.cluster_id IS '关联集群ID'; + + +-- +-- Name: COLUMN system_logs."timestamp"; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs."timestamp" IS '日志时间戳'; + + +-- +-- Name: COLUMN system_logs.host; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.host IS '主机名'; + + +-- +-- Name: COLUMN system_logs.service; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.service IS '服务名'; + + +-- +-- Name: COLUMN system_logs.source; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.source IS '来源'; + + +-- +-- Name: COLUMN system_logs.log_level; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.log_level IS '日志级别(DEBUG/INFO/WARN/ERROR/FATAL)'; + + +-- +-- Name: COLUMN system_logs.message; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.message IS '日志消息'; + + +-- +-- Name: COLUMN system_logs.exception; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.exception IS '异常堆栈'; + + +-- +-- Name: COLUMN system_logs.raw_log; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.raw_log IS '原始日志内容'; + + +-- +-- Name: COLUMN system_logs.processed; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.processed IS '是否已处理'; + + +-- +-- Name: COLUMN system_logs.created_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.system_logs.created_at IS '创建时间'; + + +-- +-- Name: system_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +ALTER TABLE public.system_logs ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME public.system_logs_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: user_cluster_mapping; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.user_cluster_mapping ( + id bigint NOT NULL, + user_id bigint NOT NULL, + cluster_id bigint NOT NULL, + role_id bigint NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE public.user_cluster_mapping OWNER TO postgres; + +-- +-- Name: TABLE user_cluster_mapping; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.user_cluster_mapping IS '用户与集群映射表'; + + +-- +-- Name: COLUMN user_cluster_mapping.id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.user_cluster_mapping.id IS '主键ID'; + + +-- +-- Name: COLUMN user_cluster_mapping.user_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.user_cluster_mapping.user_id IS '用户ID'; + + +-- +-- Name: COLUMN user_cluster_mapping.cluster_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.user_cluster_mapping.cluster_id IS '集群ID'; + + +-- +-- Name: COLUMN user_cluster_mapping.role_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.user_cluster_mapping.role_id IS '角色ID'; + + +-- +-- Name: COLUMN user_cluster_mapping.created_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.user_cluster_mapping.created_at IS '创建时间'; + + +-- +-- Name: user_cluster_mapping_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +ALTER TABLE public.user_cluster_mapping ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME public.user_cluster_mapping_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: user_role_mapping; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.user_role_mapping ( + user_id bigint NOT NULL, + role_id bigint NOT NULL +); + + +ALTER TABLE public.user_role_mapping OWNER TO postgres; + +-- +-- Name: TABLE user_role_mapping; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.user_role_mapping IS '用户-角色映射表'; + + +-- +-- Name: COLUMN user_role_mapping.user_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.user_role_mapping.user_id IS '用户ID'; + + +-- +-- Name: COLUMN user_role_mapping.role_id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.user_role_mapping.role_id IS '角色ID'; + + +-- +-- Name: users; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.users ( + id bigint NOT NULL, + username character varying(50) NOT NULL, + email character varying(100) NOT NULL, + password_hash character varying(255) NOT NULL, + full_name character varying(100) NOT NULL, + is_active boolean DEFAULT true NOT NULL, + last_login timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE public.users OWNER TO postgres; + +-- +-- Name: TABLE users; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON TABLE public.users IS '用户表'; + + +-- +-- Name: COLUMN users.id; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.users.id IS '主键ID'; + + +-- +-- Name: COLUMN users.username; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.users.username IS '用户名'; + + +-- +-- Name: COLUMN users.email; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.users.email IS '邮箱'; + + +-- +-- Name: COLUMN users.password_hash; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.users.password_hash IS '密码哈希'; + + +-- +-- Name: COLUMN users.full_name; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.users.full_name IS '姓名'; + + +-- +-- Name: COLUMN users.is_active; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.users.is_active IS '是否激活'; + + +-- +-- Name: COLUMN users.last_login; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.users.last_login IS '最后登录时间'; + + +-- +-- Name: COLUMN users.created_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.users.created_at IS '创建时间'; + + +-- +-- Name: COLUMN users.updated_at; Type: COMMENT; Schema: public; Owner: postgres +-- + +COMMENT ON COLUMN public.users.updated_at IS '更新时间'; + + +-- +-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +ALTER TABLE public.users ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME public.users_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Data for Name: app_configurations; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.app_configurations (id, config_type, config_key, config_value, description, is_enabled, created_at, updated_at) FROM stdin; +1 system system.name {"value": "故障检测系统"} 系统名称 t 2025-12-12 02:42:15.555003+00 2025-12-12 02:42:15.555003+00 +2 system log.retention.days {"value": 90} 日志保留天数 t 2025-12-12 02:42:15.555003+00 2025-12-12 02:42:15.555003+00 +3 system repair.auto.enabled {"value": false} 是否启用自动修复 t 2025-12-12 02:42:15.555003+00 2025-12-12 02:42:15.555003+00 +4 llm api.timeout {"value": 30} LLM API超时时间(秒) t 2025-12-12 02:42:15.555003+00 2025-12-12 02:42:15.555003+00 +5 alert_rule CPU使用率过高 {"metric": "cpu_usage", "severity": "high", "condition": ">", "threshold": 85} CPU使用率超过85%时触发告警 t 2025-12-12 02:42:15.555835+00 2025-12-12 02:42:15.555835+00 +6 alert_rule 内存使用率过高 {"metric": "memory_usage", "severity": "high", "condition": ">", "threshold": 90} 内存使用率超过90%时触发告警 t 2025-12-12 02:42:15.555835+00 2025-12-12 02:42:15.555835+00 +7 alert_rule 节点离线 {"value": "offline", "metric": "node_status", "severity": "critical", "condition": "="} 节点离线时触发告警 t 2025-12-12 02:42:15.555835+00 2025-12-12 02:42:15.555835+00 +8 notification 默认邮件通知 {"type": "email", "triggers": ["high", "critical"], "recipients": ["admin@example.com"]} 向管理员发送高危和严重故障的邮件通知 t 2025-12-12 02:42:15.556355+00 2025-12-12 02:42:15.556355+00 +\. + + +-- +-- Data for Name: audit_logs; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.audit_logs (id, user_id, cluster_id, role_id, username, action, resource_type, resource_id, ip_address, request_data, response_status, created_at) FROM stdin; +\. + + +-- +-- Data for Name: clusters; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.clusters (id, uuid, name, type, node_count, health_status, description, config_info, created_at, updated_at) FROM stdin; +1 a1b2c3d4-e5f6-7890-1234-567890abcdef Hadoop主集群 Hadoop 0 unknown 生产环境主Hadoop集群 {"namenode_uri": "hdfs://nn1.hadoop.prod:8020"} 2025-12-12 02:42:15.548794+00 2025-12-12 02:42:15.548794+00 +2 b2c3d4e5-f6a7-8901-2345-67890abcdef1 Hadoop测试集群 Hadoop 0 unknown 用于测试的Hadoop集群 {"namenode_uri": "hdfs://nn.hadoop.test:8020"} 2025-12-12 02:42:15.548794+00 2025-12-12 02:42:15.548794+00 +\. + + +-- +-- Data for Name: exec_logs; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.exec_logs (id, exec_id, fault_id, command_type, script_path, command_content, target_nodes, risk_level, execution_status, start_time, end_time, duration, stdout_log, stderr_log, exit_code, operator, created_at, updated_at) FROM stdin; +\. + + +-- +-- Data for Name: nodes; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.nodes (id, uuid, cluster_id, hostname, ip_address, status, cpu_usage, memory_usage, disk_usage, last_heartbeat, created_at, updated_at) FROM stdin; +\. + + +-- +-- Data for Name: permissions; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.permissions (id, permission_name, permission_key, description, created_at) FROM stdin; +19 用户管理 user:manage 用户的创建、修改、删除与查询 2025-12-14 07:35:24.029806+00 +20 角色分配 role:assign 为用户分配角色 2025-12-14 07:35:24.072852+00 +21 权限策略管理 policy:manage 维护权限策略与分配 2025-12-14 07:35:24.126385+00 +22 审计日志管理 audit:manage 审计日志的查询与清理管理 2025-12-14 07:35:24.167929+00 +23 集群列表查看 cluster:list:read 查看集群列表与状态 2025-12-14 07:35:24.209617+00 +24 集群列表管理 cluster:list:manage 新增/修改/删除集群 2025-12-14 07:35:24.265104+00 +25 日志查询 log:query 查询系统或业务日志 2025-12-14 07:35:24.307086+00 +26 日志管理 log:manage 日志清理、归档或删除 2025-12-14 07:35:24.357143+00 +27 故障诊断 fault:diagnose 执行故障分析操作 2025-12-14 07:35:24.399563+00 +28 执行日志查看 exec_log:read 查看执行日志记录 2025-12-14 07:35:24.454338+00 +29 执行日志管理 exec_log:manage 管理执行日志(例如删除) 2025-12-14 07:35:24.496722+00 +30 系统配置 system:config 系统配置与参数维护 2025-12-14 07:35:24.554589+00 +\. + + +-- +-- Data for Name: repair_templates; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.repair_templates (id, template_name, fault_type, script_content, risk_level, description, parameters, created_by, created_at, updated_at) FROM stdin; +\. + + +-- +-- Data for Name: role_permission_mapping; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.role_permission_mapping (role_id, permission_id) FROM stdin; +7 19 +7 20 +7 21 +7 22 +7 23 +7 24 +7 25 +7 26 +7 27 +7 28 +7 29 +7 30 +8 23 +8 24 +8 25 +8 26 +8 27 +8 28 +8 29 +10 23 +10 25 +10 26 +10 28 +\. + + +-- +-- Data for Name: roles; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.roles (id, role_name, role_key, description, is_system_role, created_at, updated_at) FROM stdin; +7 管理员 admin 拥有所有权限 t 2025-12-14 07:33:23.611365+00 2025-12-14 07:33:23.611365+00 +8 操作员 operator 除系统管理外的操作权限 t 2025-12-14 07:33:23.653257+00 2025-12-14 07:33:23.653257+00 +10 观察员 observer 基于操作员的只读子集 t 2025-12-14 07:34:28.548724+00 2025-12-14 07:34:28.548724+00 +\. + + +-- +-- Data for Name: system_logs; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.system_logs (id, log_id, fault_id, cluster_id, "timestamp", host, service, source, log_level, message, exception, raw_log, processed, created_at) FROM stdin; +\. + + +-- +-- Data for Name: user_cluster_mapping; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.user_cluster_mapping (id, user_id, cluster_id, role_id, created_at) FROM stdin; +\. + + +-- +-- Data for Name: user_role_mapping; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.user_role_mapping (user_id, role_id) FROM stdin; +4 7 +3 7 +\. + + +-- +-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.users (id, username, email, password_hash, full_name, is_active, last_login, created_at, updated_at) FROM stdin; +4 bdmin bdmin@qq.com $2b$12$.jKVn3UqH/w0Ajdi01aqY.K70z8QEtLlgL45u883hKp2sWREYG4Om bdmin t 2025-12-12 07:47:22.734564+00 2025-12-12 07:15:29.72108+00 2025-12-12 07:47:22.734564+00 +3 admin admin@qq.com $2b$12$F85LDEh5BP3G9VY9q/ALh.YpRNn.ob5fZM3fcfu.8G/B/WNgeBZPS admin t 2025-12-12 07:47:31.178442+00 2025-12-12 06:58:05.785083+00 2025-12-12 07:47:31.178442+00 +\. + + +-- +-- Name: app_configurations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.app_configurations_id_seq', 9, true); + + +-- +-- Name: audit_logs_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.audit_logs_id_seq', 1, false); + + +-- +-- Name: clusters_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.clusters_id_seq', 2, true); + + +-- +-- Name: exec_logs_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.exec_logs_id_seq', 1, false); + + +-- +-- Name: nodes_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.nodes_id_seq', 1, false); + + +-- +-- Name: permissions_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.permissions_id_seq', 30, true); + + +-- +-- Name: repair_templates_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.repair_templates_id_seq', 1, false); + + +-- +-- Name: roles_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.roles_id_seq', 10, true); + + +-- +-- Name: system_logs_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.system_logs_id_seq', 1, false); + + +-- +-- Name: user_cluster_mapping_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.user_cluster_mapping_id_seq', 2, true); + + +-- +-- Name: users_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.users_id_seq', 4, true); + + +-- +-- Name: app_configurations app_configurations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.app_configurations + ADD CONSTRAINT app_configurations_pkey PRIMARY KEY (id); + + +-- +-- Name: audit_logs audit_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.audit_logs + ADD CONSTRAINT audit_logs_pkey PRIMARY KEY (id); + + +-- +-- Name: clusters clusters_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.clusters + ADD CONSTRAINT clusters_name_key UNIQUE (name); + + +-- +-- Name: clusters clusters_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.clusters + ADD CONSTRAINT clusters_pkey PRIMARY KEY (id); + + +-- +-- Name: clusters clusters_uuid_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.clusters + ADD CONSTRAINT clusters_uuid_key UNIQUE (uuid); + + +-- +-- Name: exec_logs exec_logs_exec_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.exec_logs + ADD CONSTRAINT exec_logs_exec_id_key UNIQUE (exec_id); + + +-- +-- Name: exec_logs exec_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.exec_logs + ADD CONSTRAINT exec_logs_pkey PRIMARY KEY (id); + + +-- +-- Name: nodes nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.nodes + ADD CONSTRAINT nodes_pkey PRIMARY KEY (id); + + +-- +-- Name: nodes nodes_uuid_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.nodes + ADD CONSTRAINT nodes_uuid_key UNIQUE (uuid); + + +-- +-- Name: permissions permissions_permission_key_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.permissions + ADD CONSTRAINT permissions_permission_key_key UNIQUE (permission_key); + + +-- +-- Name: permissions permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.permissions + ADD CONSTRAINT permissions_pkey PRIMARY KEY (id); + + +-- +-- Name: repair_templates repair_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.repair_templates + ADD CONSTRAINT repair_templates_pkey PRIMARY KEY (id); + + +-- +-- Name: repair_templates repair_templates_template_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.repair_templates + ADD CONSTRAINT repair_templates_template_name_key UNIQUE (template_name); + + +-- +-- Name: role_permission_mapping role_permission_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.role_permission_mapping + ADD CONSTRAINT role_permission_mapping_pkey PRIMARY KEY (role_id, permission_id); + + +-- +-- Name: roles roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.roles + ADD CONSTRAINT roles_pkey PRIMARY KEY (id); + + +-- +-- Name: roles roles_role_key_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.roles + ADD CONSTRAINT roles_role_key_key UNIQUE (role_key); + + +-- +-- Name: system_logs system_logs_log_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.system_logs + ADD CONSTRAINT system_logs_log_id_key UNIQUE (log_id); + + +-- +-- Name: system_logs system_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.system_logs + ADD CONSTRAINT system_logs_pkey PRIMARY KEY (id); + + +-- +-- Name: app_configurations uk_app_config; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.app_configurations + ADD CONSTRAINT uk_app_config UNIQUE (config_type, config_key); + + +-- +-- Name: user_cluster_mapping uk_user_cluster; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.user_cluster_mapping + ADD CONSTRAINT uk_user_cluster UNIQUE (user_id, cluster_id); + + +-- +-- Name: user_cluster_mapping user_cluster_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.user_cluster_mapping + ADD CONSTRAINT user_cluster_mapping_pkey PRIMARY KEY (id); + + +-- +-- Name: user_role_mapping user_role_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.user_role_mapping + ADD CONSTRAINT user_role_mapping_pkey PRIMARY KEY (user_id, role_id); + + +-- +-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT users_email_key UNIQUE (email); + + +-- +-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT users_pkey PRIMARY KEY (id); + + +-- +-- Name: users users_username_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT users_username_key UNIQUE (username); + + +-- +-- Name: idx_app_config_enabled; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_app_config_enabled ON public.app_configurations USING btree (is_enabled); + + +-- +-- Name: idx_audit_logs_action; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_audit_logs_action ON public.audit_logs USING btree (action); + + +-- +-- Name: idx_audit_logs_cluster_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_audit_logs_cluster_id ON public.audit_logs USING btree (cluster_id); + + +-- +-- Name: idx_audit_logs_created_at; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_audit_logs_created_at ON public.audit_logs USING btree (created_at); + + +-- +-- Name: idx_audit_logs_role_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_audit_logs_role_id ON public.audit_logs USING btree (role_id); + + +-- +-- Name: idx_audit_logs_user_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_audit_logs_user_id ON public.audit_logs USING btree (user_id); + + +-- +-- Name: idx_exec_logs_end_time; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_exec_logs_end_time ON public.exec_logs USING btree (end_time); + + +-- +-- Name: idx_exec_logs_fault_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_exec_logs_fault_id ON public.exec_logs USING btree (fault_id); + + +-- +-- Name: idx_exec_logs_start_time; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_exec_logs_start_time ON public.exec_logs USING btree (start_time); + + +-- +-- Name: idx_exec_logs_status; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_exec_logs_status ON public.exec_logs USING btree (execution_status); + + +-- +-- Name: idx_nodes_cluster_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_nodes_cluster_id ON public.nodes USING btree (cluster_id); + + +-- +-- Name: idx_nodes_ip_address; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_nodes_ip_address ON public.nodes USING btree (ip_address); + + +-- +-- Name: idx_nodes_last_heartbeat; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_nodes_last_heartbeat ON public.nodes USING btree (last_heartbeat); + + +-- +-- Name: idx_nodes_status; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_nodes_status ON public.nodes USING btree (status); + + +-- +-- Name: idx_repair_templates_fault_type; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_repair_templates_fault_type ON public.repair_templates USING btree (fault_type); + + +-- +-- Name: idx_system_logs_cluster_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_system_logs_cluster_id ON public.system_logs USING btree (cluster_id); + + +-- +-- Name: idx_system_logs_fault_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_system_logs_fault_id ON public.system_logs USING btree (fault_id); + + +-- +-- Name: idx_system_logs_level; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_system_logs_level ON public.system_logs USING btree (log_level); + + +-- +-- Name: idx_system_logs_processed; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_system_logs_processed ON public.system_logs USING btree (processed); + + +-- +-- Name: idx_system_logs_timestamp; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_system_logs_timestamp ON public.system_logs USING btree ("timestamp"); + + +-- +-- Name: uk_cluster_hostname; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX uk_cluster_hostname ON public.nodes USING btree (cluster_id, hostname); + + +-- +-- Name: audit_logs audit_logs_cluster_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.audit_logs + ADD CONSTRAINT audit_logs_cluster_id_fkey FOREIGN KEY (cluster_id) REFERENCES public.clusters(id) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: audit_logs audit_logs_role_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.audit_logs + ADD CONSTRAINT audit_logs_role_id_fkey FOREIGN KEY (role_id) REFERENCES public.roles(id) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: audit_logs audit_logs_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.audit_logs + ADD CONSTRAINT audit_logs_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: nodes nodes_cluster_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.nodes + ADD CONSTRAINT nodes_cluster_id_fkey FOREIGN KEY (cluster_id) REFERENCES public.clusters(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: role_permission_mapping role_permission_mapping_permission_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.role_permission_mapping + ADD CONSTRAINT role_permission_mapping_permission_id_fkey FOREIGN KEY (permission_id) REFERENCES public.permissions(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: role_permission_mapping role_permission_mapping_role_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.role_permission_mapping + ADD CONSTRAINT role_permission_mapping_role_id_fkey FOREIGN KEY (role_id) REFERENCES public.roles(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: system_logs system_logs_cluster_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.system_logs + ADD CONSTRAINT system_logs_cluster_id_fkey FOREIGN KEY (cluster_id) REFERENCES public.clusters(id) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: user_cluster_mapping user_cluster_mapping_cluster_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.user_cluster_mapping + ADD CONSTRAINT user_cluster_mapping_cluster_id_fkey FOREIGN KEY (cluster_id) REFERENCES public.clusters(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: user_cluster_mapping user_cluster_mapping_role_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.user_cluster_mapping + ADD CONSTRAINT user_cluster_mapping_role_id_fkey FOREIGN KEY (role_id) REFERENCES public.roles(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: user_cluster_mapping user_cluster_mapping_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.user_cluster_mapping + ADD CONSTRAINT user_cluster_mapping_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: user_role_mapping user_role_mapping_role_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.user_role_mapping + ADD CONSTRAINT user_role_mapping_role_id_fkey FOREIGN KEY (role_id) REFERENCES public.roles(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: user_role_mapping user_role_mapping_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.user_role_mapping + ADD CONSTRAINT user_role_mapping_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: pg_database_owner +-- + +GRANT USAGE ON SCHEMA public TO echo; + + +-- +-- Name: TABLE app_configurations; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.app_configurations TO echo; + + +-- +-- Name: SEQUENCE app_configurations_id_seq; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT ALL ON SEQUENCE public.app_configurations_id_seq TO echo; + + +-- +-- Name: TABLE audit_logs; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.audit_logs TO echo; + + +-- +-- Name: SEQUENCE audit_logs_id_seq; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT ALL ON SEQUENCE public.audit_logs_id_seq TO echo; + + +-- +-- Name: TABLE clusters; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.clusters TO echo; + + +-- +-- Name: SEQUENCE clusters_id_seq; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT ALL ON SEQUENCE public.clusters_id_seq TO echo; + + +-- +-- Name: TABLE exec_logs; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.exec_logs TO echo; + + +-- +-- Name: SEQUENCE exec_logs_id_seq; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT ALL ON SEQUENCE public.exec_logs_id_seq TO echo; + + +-- +-- Name: TABLE nodes; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.nodes TO echo; + + +-- +-- Name: SEQUENCE nodes_id_seq; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT ALL ON SEQUENCE public.nodes_id_seq TO echo; + + +-- +-- Name: TABLE permissions; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.permissions TO echo; + + +-- +-- Name: SEQUENCE permissions_id_seq; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT ALL ON SEQUENCE public.permissions_id_seq TO echo; + + +-- +-- Name: TABLE repair_templates; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.repair_templates TO echo; + + +-- +-- Name: SEQUENCE repair_templates_id_seq; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT ALL ON SEQUENCE public.repair_templates_id_seq TO echo; + + +-- +-- Name: TABLE role_permission_mapping; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.role_permission_mapping TO echo; + + +-- +-- Name: TABLE roles; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.roles TO echo; + + +-- +-- Name: SEQUENCE roles_id_seq; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT ALL ON SEQUENCE public.roles_id_seq TO echo; + + +-- +-- Name: TABLE system_logs; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.system_logs TO echo; + + +-- +-- Name: SEQUENCE system_logs_id_seq; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT ALL ON SEQUENCE public.system_logs_id_seq TO echo; + + +-- +-- Name: TABLE user_cluster_mapping; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.user_cluster_mapping TO echo; + + +-- +-- Name: SEQUENCE user_cluster_mapping_id_seq; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT ALL ON SEQUENCE public.user_cluster_mapping_id_seq TO echo; + + +-- +-- Name: TABLE user_role_mapping; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.user_role_mapping TO echo; + + +-- +-- Name: TABLE users; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.users TO echo; + + +-- +-- Name: SEQUENCE users_id_seq; Type: ACL; Schema: public; Owner: postgres +-- + +GRANT ALL ON SEQUENCE public.users_id_seq TO echo; + + +-- +-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: public; Owner: postgres +-- + +ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO echo; + + +-- +-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: postgres +-- + +ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT SELECT,INSERT,DELETE,UPDATE ON TABLES TO echo; + + +-- +-- PostgreSQL database dump complete +-- + +\unrestrict x3vbKb2vAIlctC0uebdrXag55BFVsJBRQxqhKA1MdoFQjC3OJ9m4YZLeFNLKBRA + diff --git a/backend/hadoop_fault.dump b/backend/hadoop_fault.dump new file mode 100644 index 0000000000000000000000000000000000000000..6f2e4d3047d9ddd551755fc8cd5c8dd44a0ac705 GIT binary patch literal 75995 zcmd5_2Yl2;_Fp5&NwI*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@P<6_bm*eYoo27wr#r zPX2oTr4Oy>K4j2}0)(dxB+WO;ThevMwy3g}J{dbzIf9Nh3 zk&2-!OGcs|dD*M`&bRdKe&~&rgWLYv*8a#vKec{d&_DIwt)cO|E?@G7`?-0Ydw1=A z=@m6Yj;%TpeAK?~gsrY=*bm3{u79{s=J@j=5jXqt;iDB9a^dA9M>lV>*+4?6Nm zQPInXU;F%)w-5aL?`x0LuInNB8&AHvs#o^d?3V6#6*c#03HBIwLHF0T-PN+~uDiZ_ zt$UA_!$rG#bpQHQ|D>kjYd-k7=BrDW{QgwuEsn(lPC3@5)~3vScIFQ!KRmhd?bKD@ z-%{Bv|FYZ0j%#TtI(*YLU6+My>7U%PbN`7GKb^Ya+GTf?-T6xCo!RS;eEc2gu^;4& zxN`mXt+RIC_QSDVy{^rgi-v2H< zu=S1WzX^=*E`4nCWZg9GX!)Q|hn~CdhP7`k=`&^7h2IaTc=hJ%wr%az)HDCjRZq-p vx$oGflOI{0sN9g;`}SM6F1=#fz0cVS-@g5|KkfUh^Stw1t?y0hi~#>1&9{uP literal 0 HcmV?d00001 diff --git a/backend/insert_dump.sql b/backend/insert_dump.sql new file mode 100644 index 0000000..e69de29 diff --git a/backend/insert_summary.txt b/backend/insert_summary.txt new file mode 100644 index 0000000..e69de29 diff --git a/backend/tests/test_llm.py b/backend/tests/test_llm.py new file mode 100644 index 0000000..f3c4ed9 --- /dev/null +++ b/backend/tests/test_llm.py @@ -0,0 +1,43 @@ +import asyncio +import os +import sys + +# Add backend directory to sys.path to import app modules +# Current file: backend/tests/test_llm.py +# Parent: backend/tests +# Grandparent: backend +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from app.services.llm import LLMClient +from dotenv import load_dotenv + +async def main(): + # Load .env from backend directory + env_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), ".env") + load_dotenv(env_path) + + print("Testing LLMClient...") + try: + llm = LLMClient() + print(f"Provider: {llm.provider}") + print(f"Endpoint: {llm.endpoint}") + print(f"Model: {llm.model}") + + messages = [{"role": "user", "content": "你好"}] + print("Sending request...") + resp = await llm.chat(messages) + print("Response received:") + # Check for reasoning content since we use DeepSeek R1 + if "choices" in resp and resp["choices"]: + msg = resp["choices"][0].get("message", {}) + print(f"Reply: {msg.get('content')}") + if "reasoning_content" in msg: + print(f"Reasoning: {msg.get('reasoning_content')[:100]}...") # Print first 100 chars + else: + print(resp) + + except Exception as e: + print(f"Error: {e}") + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/insert_dump.sql b/insert_dump.sql new file mode 100644 index 0000000..b33dff3 --- /dev/null +++ b/insert_dump.sql @@ -0,0 +1,2167 @@ +-- +-- PostgreSQL database dump +-- + +\restrict Uu5RUeD7W50Ldfv5i1NSxXc0jR7r8L5p2hetPJEHpgrfI5ZxVEjRijvDSKNmtSn + +-- Dumped from database version 15.15 (Debian 15.15-1.pgdg13+1) +-- Dumped by pg_dump version 15.15 (Debian 15.15-1.pgdg13+1) + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: app_configurations; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE app_configurations ( + id bigint NOT NULL, + config_type character varying(20) NOT NULL, + config_key character varying(100) NOT NULL, + config_value jsonb NOT NULL, + description character varying(500), + is_enabled boolean DEFAULT true NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT app_config_type_chk CHECK (((config_type)::text = ANY ((ARRAY['system'::character varying, 'alert_rule'::character varying, 'notification'::character varying, 'llm'::character varying])::text[]))) +); + + +ALTER TABLE app_configurations OWNER TO postgres; + +-- +-- Name: TABLE app_configurations; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE app_configurations IS '应用统一配置表'; + + +-- +-- Name: COLUMN app_configurations.id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN app_configurations.id IS '主键ID'; + + +-- +-- Name: COLUMN app_configurations.config_type; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN app_configurations.config_type IS '配置类型(system/alert_rule/notification/llm)'; + + +-- +-- Name: COLUMN app_configurations.config_key; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN app_configurations.config_key IS '配置键'; + + +-- +-- Name: COLUMN app_configurations.config_value; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN app_configurations.config_value IS '配置值(JSONB)'; + + +-- +-- Name: COLUMN app_configurations.description; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN app_configurations.description IS '配置描述'; + + +-- +-- Name: COLUMN app_configurations.is_enabled; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN app_configurations.is_enabled IS '是否启用'; + + +-- +-- Name: COLUMN app_configurations.created_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN app_configurations.created_at IS '创建时间'; + + +-- +-- Name: COLUMN app_configurations.updated_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN app_configurations.updated_at IS '更新时间'; + + +-- +-- Name: app_configurations_id_seq; Type: SEQUENCE; Schema: Owner: postgres +-- + +ALTER TABLE app_configurations ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME app_configurations_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: audit_logs; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE audit_logs ( + id bigint NOT NULL, + user_id bigint, + cluster_id bigint, + role_id bigint, + username character varying(50) NOT NULL, + action character varying(100) NOT NULL, + resource_type character varying(50) NOT NULL, + resource_id character varying(100), + ip_address inet NOT NULL, + request_data jsonb, + response_status integer, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE audit_logs OWNER TO postgres; + +-- +-- Name: TABLE audit_logs; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE audit_logs IS '操作审计表'; + + +-- +-- Name: COLUMN audit_logs.id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN audit_logs.id IS '主键ID'; + + +-- +-- Name: COLUMN audit_logs.user_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN audit_logs.user_id IS '用户ID'; + + +-- +-- Name: COLUMN audit_logs.cluster_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN audit_logs.cluster_id IS '集群ID'; + + +-- +-- Name: COLUMN audit_logs.role_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN audit_logs.role_id IS '角色ID'; + + +-- +-- Name: COLUMN audit_logs.username; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN audit_logs.username IS '用户名'; + + +-- +-- Name: COLUMN audit_logs.action; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN audit_logs.action IS '操作动作'; + + +-- +-- Name: COLUMN audit_logs.resource_type; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN audit_logs.resource_type IS '资源类型'; + + +-- +-- Name: COLUMN audit_logs.resource_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN audit_logs.resource_id IS '资源ID'; + + +-- +-- Name: COLUMN audit_logs.ip_address; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN audit_logs.ip_address IS '请求来源IP(INET, 兼容IPv4/IPv6)'; + + +-- +-- Name: COLUMN audit_logs.request_data; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN audit_logs.request_data IS '请求数据(JSONB)'; + + +-- +-- Name: COLUMN audit_logs.response_status; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN audit_logs.response_status IS '响应状态码'; + + +-- +-- Name: COLUMN audit_logs.created_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN audit_logs.created_at IS '创建时间'; + + +-- +-- Name: audit_logs_id_seq; Type: SEQUENCE; Schema: Owner: postgres +-- + +ALTER TABLE audit_logs ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME audit_logs_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: clusters; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE clusters ( + id bigint NOT NULL, + uuid uuid NOT NULL, + name character varying(100) NOT NULL, + type character varying(50) NOT NULL, + node_count integer DEFAULT 0 NOT NULL, + health_status character varying(20) DEFAULT 'unknown'::character varying NOT NULL, + description text, + config_info jsonb, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT clusters_health_status_chk CHECK (((health_status)::text = ANY ((ARRAY['healthy'::character varying, 'warning'::character varying, 'error'::character varying, 'unknown'::character varying])::text[]))) +); + + +ALTER TABLE clusters OWNER TO postgres; + +-- +-- Name: TABLE clusters; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE clusters IS '集群信息表'; + + +-- +-- Name: COLUMN clusters.id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN clusters.id IS '主键ID'; + + +-- +-- Name: COLUMN clusters.uuid; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN clusters.uuid IS '集群唯一标识(UUID)'; + + +-- +-- Name: COLUMN clusters.name; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN clusters.name IS '集群名称'; + + +-- +-- Name: COLUMN clusters.type; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN clusters.type IS '集群类型'; + + +-- +-- Name: COLUMN clusters.node_count; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN clusters.node_count IS '集群节点数量'; + + +-- +-- Name: COLUMN clusters.health_status; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN clusters.health_status IS '集群健康状态(healthy/warning/error/unknown)'; + + +-- +-- Name: COLUMN clusters.description; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN clusters.description IS '集群描述'; + + +-- +-- Name: COLUMN clusters.config_info; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN clusters.config_info IS '集群配置信息(JSONB)'; + + +-- +-- Name: COLUMN clusters.created_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN clusters.created_at IS '创建时间'; + + +-- +-- Name: COLUMN clusters.updated_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN clusters.updated_at IS '更新时间'; + + +-- +-- Name: clusters_id_seq; Type: SEQUENCE; Schema: Owner: postgres +-- + +ALTER TABLE clusters ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME clusters_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: exec_logs; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE exec_logs ( + id bigint NOT NULL, + exec_id character varying(32) NOT NULL, + fault_id character varying(32) NOT NULL, + command_type character varying(50) NOT NULL, + script_path character varying(255), + command_content text NOT NULL, + target_nodes jsonb, + risk_level character varying(20) DEFAULT 'medium'::character varying NOT NULL, + execution_status character varying(20) DEFAULT 'pending'::character varying NOT NULL, + start_time timestamp with time zone, + end_time timestamp with time zone, + duration integer, + stdout_log text, + stderr_log text, + exit_code integer, + operator character varying(50) DEFAULT 'system'::character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT exec_logs_duration_chk CHECK (((duration IS NULL) OR (duration >= 0))), + CONSTRAINT exec_logs_risk_chk CHECK (((risk_level)::text = ANY ((ARRAY['low'::character varying, 'medium'::character varying, 'high'::character varying])::text[]))), + CONSTRAINT exec_logs_status_chk CHECK (((execution_status)::text = ANY ((ARRAY['pending'::character varying, 'running'::character varying, 'success'::character varying, 'failed'::character varying, 'timeout'::character varying])::text[]))) +); + + +ALTER TABLE exec_logs OWNER TO postgres; + +-- +-- Name: TABLE exec_logs; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE exec_logs IS '执行日志表'; + + +-- +-- Name: COLUMN exec_logs.id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.id IS '主键ID'; + + +-- +-- Name: COLUMN exec_logs.exec_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.exec_id IS '执行唯一标识'; + + +-- +-- Name: COLUMN exec_logs.fault_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.fault_id IS '关联故障标识(无外键)'; + + +-- +-- Name: COLUMN exec_logs.command_type; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.command_type IS '命令类型'; + + +-- +-- Name: COLUMN exec_logs.script_path; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.script_path IS '脚本路径'; + + +-- +-- Name: COLUMN exec_logs.command_content; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.command_content IS '执行的命令内容'; + + +-- +-- Name: COLUMN exec_logs.target_nodes; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.target_nodes IS '目标执行节点(JSONB)'; + + +-- +-- Name: COLUMN exec_logs.risk_level; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.risk_level IS '风险级别(low/medium/high)'; + + +-- +-- Name: COLUMN exec_logs.execution_status; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.execution_status IS '执行状态(pending/running/success/failed/timeout)'; + + +-- +-- Name: COLUMN exec_logs.start_time; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.start_time IS '开始执行时间'; + + +-- +-- Name: COLUMN exec_logs.end_time; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.end_time IS '结束执行时间'; + + +-- +-- Name: COLUMN exec_logs.duration; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.duration IS '执行时长(秒)'; + + +-- +-- Name: COLUMN exec_logs.stdout_log; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.stdout_log IS '标准输出日志'; + + +-- +-- Name: COLUMN exec_logs.stderr_log; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.stderr_log IS '错误输出日志'; + + +-- +-- Name: COLUMN exec_logs.exit_code; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.exit_code IS '退出码'; + + +-- +-- Name: COLUMN exec_logs.operator; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.operator IS '操作人'; + + +-- +-- Name: COLUMN exec_logs.created_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.created_at IS '创建时间'; + + +-- +-- Name: COLUMN exec_logs.updated_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN exec_logs.updated_at IS '更新时间'; + + +-- +-- Name: exec_logs_id_seq; Type: SEQUENCE; Schema: Owner: postgres +-- + +ALTER TABLE exec_logs ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME exec_logs_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: nodes; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE nodes ( + id bigint NOT NULL, + uuid uuid NOT NULL, + cluster_id bigint NOT NULL, + hostname character varying(100) NOT NULL, + ip_address inet NOT NULL, + status character varying(20) DEFAULT 'unknown'::character varying NOT NULL, + cpu_usage numeric(5,2), + memory_usage numeric(5,2), + disk_usage numeric(5,2), + last_heartbeat timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT nodes_cpu_chk CHECK (((cpu_usage IS NULL) OR ((cpu_usage >= (0)::numeric) AND (cpu_usage <= (100)::numeric)))), + CONSTRAINT nodes_disk_chk CHECK (((disk_usage IS NULL) OR ((disk_usage >= (0)::numeric) AND (disk_usage <= (100)::numeric)))), + CONSTRAINT nodes_mem_chk CHECK (((memory_usage IS NULL) OR ((memory_usage >= (0)::numeric) AND (memory_usage <= (100)::numeric)))), + CONSTRAINT nodes_status_chk CHECK (((status)::text = ANY ((ARRAY['healthy'::character varying, 'unhealthy'::character varying, 'warning'::character varying, 'unknown'::character varying])::text[]))) +); + + +ALTER TABLE nodes OWNER TO postgres; + +-- +-- Name: TABLE nodes; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE nodes IS '节点信息表'; + + +-- +-- Name: COLUMN nodes.id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN nodes.id IS '主键ID'; + + +-- +-- Name: COLUMN nodes.uuid; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN nodes.uuid IS '节点唯一标识(UUID)'; + + +-- +-- Name: COLUMN nodes.cluster_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN nodes.cluster_id IS '所属集群ID'; + + +-- +-- Name: COLUMN nodes.hostname; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN nodes.hostname IS '节点主机名'; + + +-- +-- Name: COLUMN nodes.ip_address; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN nodes.ip_address IS '节点IP地址(INET, 兼容IPv4/IPv6)'; + + +-- +-- Name: COLUMN nodes.status; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN nodes.status IS '节点健康状态(healthy/unhealthy/warning/unknown)'; + + +-- +-- Name: COLUMN nodes.cpu_usage; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN nodes.cpu_usage IS 'CPU使用率(%)'; + + +-- +-- Name: COLUMN nodes.memory_usage; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN nodes.memory_usage IS '内存使用率(%)'; + + +-- +-- Name: COLUMN nodes.disk_usage; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN nodes.disk_usage IS '磁盘使用率(%)'; + + +-- +-- Name: COLUMN nodes.last_heartbeat; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN nodes.last_heartbeat IS '最后心跳时间'; + + +-- +-- Name: COLUMN nodes.created_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN nodes.created_at IS '创建时间'; + + +-- +-- Name: COLUMN nodes.updated_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN nodes.updated_at IS '更新时间'; + + +-- +-- Name: nodes_id_seq; Type: SEQUENCE; Schema: Owner: postgres +-- + +ALTER TABLE nodes ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME nodes_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: permissions; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE permissions ( + id bigint NOT NULL, + permission_name character varying(100) NOT NULL, + permission_key character varying(100) NOT NULL, + description character varying(255), + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE permissions OWNER TO postgres; + +-- +-- Name: TABLE permissions; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE permissions IS '权限表'; + + +-- +-- Name: COLUMN permissions.id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN permissions.id IS '主键ID'; + + +-- +-- Name: COLUMN permissions.permission_name; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN permissions.permission_name IS '权限名称'; + + +-- +-- Name: COLUMN permissions.permission_key; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN permissions.permission_key IS '权限唯一标识'; + + +-- +-- Name: COLUMN permissions.description; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN permissions.description IS '权限描述'; + + +-- +-- Name: COLUMN permissions.created_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN permissions.created_at IS '创建时间'; + + +-- +-- Name: permissions_id_seq; Type: SEQUENCE; Schema: Owner: postgres +-- + +ALTER TABLE permissions ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME permissions_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: repair_templates; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE repair_templates ( + id bigint NOT NULL, + template_name character varying(100) NOT NULL, + fault_type character varying(50) NOT NULL, + script_content text NOT NULL, + risk_level character varying(20) DEFAULT 'medium'::character varying NOT NULL, + description text, + parameters jsonb, + created_by character varying(50), + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT repair_templates_risk_chk CHECK (((risk_level)::text = ANY ((ARRAY['low'::character varying, 'medium'::character varying, 'high'::character varying])::text[]))) +); + + +ALTER TABLE repair_templates OWNER TO postgres; + +-- +-- Name: TABLE repair_templates; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE repair_templates IS '修复脚本模板表'; + + +-- +-- Name: COLUMN repair_templates.id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN repair_templates.id IS '主键ID'; + + +-- +-- Name: COLUMN repair_templates.template_name; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN repair_templates.template_name IS '模板名称'; + + +-- +-- Name: COLUMN repair_templates.fault_type; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN repair_templates.fault_type IS '适用故障类型'; + + +-- +-- Name: COLUMN repair_templates.script_content; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN repair_templates.script_content IS '脚本内容'; + + +-- +-- Name: COLUMN repair_templates.risk_level; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN repair_templates.risk_level IS '风险级别(low/medium/high)'; + + +-- +-- Name: COLUMN repair_templates.description; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN repair_templates.description IS '模板描述'; + + +-- +-- Name: COLUMN repair_templates.parameters; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN repair_templates.parameters IS '模板参数定义(JSONB)'; + + +-- +-- Name: COLUMN repair_templates.created_by; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN repair_templates.created_by IS '创建人'; + + +-- +-- Name: COLUMN repair_templates.created_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN repair_templates.created_at IS '创建时间'; + + +-- +-- Name: COLUMN repair_templates.updated_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN repair_templates.updated_at IS '更新时间'; + + +-- +-- Name: repair_templates_id_seq; Type: SEQUENCE; Schema: Owner: postgres +-- + +ALTER TABLE repair_templates ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME repair_templates_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: role_permission_mapping; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE role_permission_mapping ( + role_id bigint NOT NULL, + permission_id bigint NOT NULL +); + + +ALTER TABLE role_permission_mapping OWNER TO postgres; + +-- +-- Name: TABLE role_permission_mapping; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE role_permission_mapping IS '角色-权限映射表'; + + +-- +-- Name: COLUMN role_permission_mapping.role_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN role_permission_mapping.role_id IS '角色ID'; + + +-- +-- Name: COLUMN role_permission_mapping.permission_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN role_permission_mapping.permission_id IS '权限ID'; + + +-- +-- Name: roles; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE roles ( + id bigint NOT NULL, + role_name character varying(50) NOT NULL, + role_key character varying(50) NOT NULL, + description character varying(255), + is_system_role boolean DEFAULT false NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE roles OWNER TO postgres; + +-- +-- Name: TABLE roles; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE roles IS '角色表'; + + +-- +-- Name: COLUMN roles.id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN roles.id IS '主键ID'; + + +-- +-- Name: COLUMN roles.role_name; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN roles.role_name IS '角色名称'; + + +-- +-- Name: COLUMN roles.role_key; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN roles.role_key IS '角色唯一标识'; + + +-- +-- Name: COLUMN roles.description; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN roles.description IS '角色描述'; + + +-- +-- Name: COLUMN roles.is_system_role; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN roles.is_system_role IS '是否为系统内置角色'; + + +-- +-- Name: COLUMN roles.created_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN roles.created_at IS '创建时间'; + + +-- +-- Name: COLUMN roles.updated_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN roles.updated_at IS '更新时间'; + + +-- +-- Name: roles_id_seq; Type: SEQUENCE; Schema: Owner: postgres +-- + +ALTER TABLE roles ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME roles_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: system_logs; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE system_logs ( + id bigint NOT NULL, + log_id character varying(32) NOT NULL, + fault_id character varying(32), + cluster_id bigint, + "timestamp" timestamp with time zone NOT NULL, + host character varying(100) NOT NULL, + service character varying(50) NOT NULL, + source character varying(50), + log_level character varying(10) NOT NULL, + message text NOT NULL, + exception text, + raw_log text, + processed boolean DEFAULT false NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT system_logs_level_chk CHECK (((log_level)::text = ANY ((ARRAY['DEBUG'::character varying, 'INFO'::character varying, 'WARN'::character varying, 'ERROR'::character varying, 'FATAL'::character varying])::text[]))) +); + + +ALTER TABLE system_logs OWNER TO postgres; + +-- +-- Name: TABLE system_logs; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE system_logs IS '系统日志表'; + + +-- +-- Name: COLUMN system_logs.id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.id IS '主键ID'; + + +-- +-- Name: COLUMN system_logs.log_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.log_id IS '日志唯一标识'; + + +-- +-- Name: COLUMN system_logs.fault_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.fault_id IS '关联故障标识(无外键)'; + + +-- +-- Name: COLUMN system_logs.cluster_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.cluster_id IS '关联集群ID'; + + +-- +-- Name: COLUMN system_logs."timestamp"; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs."timestamp" IS '日志时间戳'; + + +-- +-- Name: COLUMN system_logs.host; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.host IS '主机名'; + + +-- +-- Name: COLUMN system_logs.service; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.service IS '服务名'; + + +-- +-- Name: COLUMN system_logs.source; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.source IS '来源'; + + +-- +-- Name: COLUMN system_logs.log_level; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.log_level IS '日志级别(DEBUG/INFO/WARN/ERROR/FATAL)'; + + +-- +-- Name: COLUMN system_logs.message; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.message IS '日志消息'; + + +-- +-- Name: COLUMN system_logs.exception; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.exception IS '异常堆栈'; + + +-- +-- Name: COLUMN system_logs.raw_log; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.raw_log IS '原始日志内容'; + + +-- +-- Name: COLUMN system_logs.processed; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.processed IS '是否已处理'; + + +-- +-- Name: COLUMN system_logs.created_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN system_logs.created_at IS '创建时间'; + + +-- +-- Name: system_logs_id_seq; Type: SEQUENCE; Schema: Owner: postgres +-- + +ALTER TABLE system_logs ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME system_logs_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: user_cluster_mapping; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE user_cluster_mapping ( + id bigint NOT NULL, + user_id bigint NOT NULL, + cluster_id bigint NOT NULL, + role_id bigint NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE user_cluster_mapping OWNER TO postgres; + +-- +-- Name: TABLE user_cluster_mapping; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE user_cluster_mapping IS '用户与集群映射表'; + + +-- +-- Name: COLUMN user_cluster_mapping.id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN user_cluster_mapping.id IS '主键ID'; + + +-- +-- Name: COLUMN user_cluster_mapping.user_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN user_cluster_mapping.user_id IS '用户ID'; + + +-- +-- Name: COLUMN user_cluster_mapping.cluster_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN user_cluster_mapping.cluster_id IS '集群ID'; + + +-- +-- Name: COLUMN user_cluster_mapping.role_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN user_cluster_mapping.role_id IS '角色ID'; + + +-- +-- Name: COLUMN user_cluster_mapping.created_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN user_cluster_mapping.created_at IS '创建时间'; + + +-- +-- Name: user_cluster_mapping_id_seq; Type: SEQUENCE; Schema: Owner: postgres +-- + +ALTER TABLE user_cluster_mapping ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME user_cluster_mapping_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Name: user_role_mapping; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE user_role_mapping ( + user_id bigint NOT NULL, + role_id bigint NOT NULL +); + + +ALTER TABLE user_role_mapping OWNER TO postgres; + +-- +-- Name: TABLE user_role_mapping; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE user_role_mapping IS '用户-角色映射表'; + + +-- +-- Name: COLUMN user_role_mapping.user_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN user_role_mapping.user_id IS '用户ID'; + + +-- +-- Name: COLUMN user_role_mapping.role_id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN user_role_mapping.role_id IS '角色ID'; + + +-- +-- Name: users; Type: TABLE; Schema: Owner: postgres +-- + +CREATE TABLE users ( + id bigint NOT NULL, + username character varying(50) NOT NULL, + email character varying(100) NOT NULL, + password_hash character varying(255) NOT NULL, + full_name character varying(100) NOT NULL, + is_active boolean DEFAULT true NOT NULL, + last_login timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE users OWNER TO postgres; + +-- +-- Name: TABLE users; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON TABLE users IS '用户表'; + + +-- +-- Name: COLUMN users.id; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN users.id IS '主键ID'; + + +-- +-- Name: COLUMN users.username; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN users.username IS '用户名'; + + +-- +-- Name: COLUMN users.email; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN users.email IS '邮箱'; + + +-- +-- Name: COLUMN users.password_hash; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN users.password_hash IS '密码哈希'; + + +-- +-- Name: COLUMN users.full_name; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN users.full_name IS '姓名'; + + +-- +-- Name: COLUMN users.is_active; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN users.is_active IS '是否激活'; + + +-- +-- Name: COLUMN users.last_login; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN users.last_login IS '最后登录时间'; + + +-- +-- Name: COLUMN users.created_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN users.created_at IS '创建时间'; + + +-- +-- Name: COLUMN users.updated_at; Type: COMMENT; Schema: Owner: postgres +-- + +COMMENT ON COLUMN users.updated_at IS '更新时间'; + + +-- +-- Name: users_id_seq; Type: SEQUENCE; Schema: Owner: postgres +-- + +ALTER TABLE users ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME users_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + + +-- +-- Data for Name: app_configurations; Type: TABLE DATA; Schema: Owner: postgres +-- + +INSERT INTO app_configurations (id, config_type, config_key, config_value, description, is_enabled, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (1, 'system', 'system.name', '{"value": "故障检测系统"}', '系统名称', true, '2025-12-12 02:42:15.555003+00', '2025-12-12 02:42:15.555003+00'); +INSERT INTO app_configurations (id, config_type, config_key, config_value, description, is_enabled, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (2, 'system', 'log.retention.days', '{"value": 90}', '日志保留天数', true, '2025-12-12 02:42:15.555003+00', '2025-12-12 02:42:15.555003+00'); +INSERT INTO app_configurations (id, config_type, config_key, config_value, description, is_enabled, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (3, 'system', 'repair.auto.enabled', '{"value": false}', '是否启用自动修复', true, '2025-12-12 02:42:15.555003+00', '2025-12-12 02:42:15.555003+00'); +INSERT INTO app_configurations (id, config_type, config_key, config_value, description, is_enabled, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (4, 'llm', 'api.timeout', '{"value": 30}', 'LLM API超时时间(秒)', true, '2025-12-12 02:42:15.555003+00', '2025-12-12 02:42:15.555003+00'); +INSERT INTO app_configurations (id, config_type, config_key, config_value, description, is_enabled, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (5, 'alert_rule', 'CPU使用率过高', '{"metric": "cpu_usage", "severity": "high", "condition": ">", "threshold": 85}', 'CPU使用率超过85%时触发告警', true, '2025-12-12 02:42:15.555835+00', '2025-12-12 02:42:15.555835+00'); +INSERT INTO app_configurations (id, config_type, config_key, config_value, description, is_enabled, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (6, 'alert_rule', '内存使用率过高', '{"metric": "memory_usage", "severity": "high", "condition": ">", "threshold": 90}', '内存使用率超过90%时触发告警', true, '2025-12-12 02:42:15.555835+00', '2025-12-12 02:42:15.555835+00'); +INSERT INTO app_configurations (id, config_type, config_key, config_value, description, is_enabled, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (7, 'alert_rule', '节点离线', '{"value": "offline", "metric": "node_status", "severity": "critical", "condition": "="}', '节点离线时触发告警', true, '2025-12-12 02:42:15.555835+00', '2025-12-12 02:42:15.555835+00'); +INSERT INTO app_configurations (id, config_type, config_key, config_value, description, is_enabled, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (8, 'notification', '默认邮件通知', '{"type": "email", "triggers": ["high", "critical"], "recipients": ["admin@example.com"]}', '向管理员发送高危和严重故障的邮件通知', true, '2025-12-12 02:42:15.556355+00', '2025-12-12 02:42:15.556355+00'); + + +-- +-- Data for Name: audit_logs; Type: TABLE DATA; Schema: Owner: postgres +-- + + + +-- +-- Data for Name: clusters; Type: TABLE DATA; Schema: Owner: postgres +-- + +INSERT INTO clusters (id, uuid, name, type, node_count, health_status, description, config_info, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (1, 'a1b2c3d4-e5f6-7890-1234-567890abcdef', 'Hadoop主集群', 'Hadoop', 0, 'unknown', '生产环境主Hadoop集群', '{"namenode_uri": "hdfs://nn1.hadoop.prod:8020"}', '2025-12-12 02:42:15.548794+00', '2025-12-12 02:42:15.548794+00'); +INSERT INTO clusters (id, uuid, name, type, node_count, health_status, description, config_info, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (2, 'b2c3d4e5-f6a7-8901-2345-67890abcdef1', 'Hadoop测试集群', 'Hadoop', 0, 'unknown', '用于测试的Hadoop集群', '{"namenode_uri": "hdfs://nn.hadoop.test:8020"}', '2025-12-12 02:42:15.548794+00', '2025-12-12 02:42:15.548794+00'); + + +-- +-- Data for Name: exec_logs; Type: TABLE DATA; Schema: Owner: postgres +-- + + + +-- +-- Data for Name: nodes; Type: TABLE DATA; Schema: Owner: postgres +-- + + + +-- +-- Data for Name: permissions; Type: TABLE DATA; Schema: Owner: postgres +-- + +INSERT INTO permissions (id, permission_name, permission_key, description, created_at) OVERRIDING SYSTEM VALUE VALUES (19, '用户管理', 'user:manage', '用户的创建、修改、删除与查询', '2025-12-14 07:35:24.029806+00'); +INSERT INTO permissions (id, permission_name, permission_key, description, created_at) OVERRIDING SYSTEM VALUE VALUES (20, '角色分配', 'role:assign', '为用户分配角色', '2025-12-14 07:35:24.072852+00'); +INSERT INTO permissions (id, permission_name, permission_key, description, created_at) OVERRIDING SYSTEM VALUE VALUES (21, '权限策略管理', 'policy:manage', '维护权限策略与分配', '2025-12-14 07:35:24.126385+00'); +INSERT INTO permissions (id, permission_name, permission_key, description, created_at) OVERRIDING SYSTEM VALUE VALUES (22, '审计日志管理', 'audit:manage', '审计日志的查询与清理管理', '2025-12-14 07:35:24.167929+00'); +INSERT INTO permissions (id, permission_name, permission_key, description, created_at) OVERRIDING SYSTEM VALUE VALUES (23, '集群列表查看', 'cluster:list:read', '查看集群列表与状态', '2025-12-14 07:35:24.209617+00'); +INSERT INTO permissions (id, permission_name, permission_key, description, created_at) OVERRIDING SYSTEM VALUE VALUES (24, '集群列表管理', 'cluster:list:manage', '新增/修改/删除集群', '2025-12-14 07:35:24.265104+00'); +INSERT INTO permissions (id, permission_name, permission_key, description, created_at) OVERRIDING SYSTEM VALUE VALUES (25, '日志查询', 'log:query', '查询系统或业务日志', '2025-12-14 07:35:24.307086+00'); +INSERT INTO permissions (id, permission_name, permission_key, description, created_at) OVERRIDING SYSTEM VALUE VALUES (26, '日志管理', 'log:manage', '日志清理、归档或删除', '2025-12-14 07:35:24.357143+00'); +INSERT INTO permissions (id, permission_name, permission_key, description, created_at) OVERRIDING SYSTEM VALUE VALUES (27, '故障诊断', 'fault:diagnose', '执行故障分析操作', '2025-12-14 07:35:24.399563+00'); +INSERT INTO permissions (id, permission_name, permission_key, description, created_at) OVERRIDING SYSTEM VALUE VALUES (28, '执行日志查看', 'exec_log:read', '查看执行日志记录', '2025-12-14 07:35:24.454338+00'); +INSERT INTO permissions (id, permission_name, permission_key, description, created_at) OVERRIDING SYSTEM VALUE VALUES (29, '执行日志管理', 'exec_log:manage', '管理执行日志(例如删除)', '2025-12-14 07:35:24.496722+00'); +INSERT INTO permissions (id, permission_name, permission_key, description, created_at) OVERRIDING SYSTEM VALUE VALUES (30, '系统配置', 'system:config', '系统配置与参数维护', '2025-12-14 07:35:24.554589+00'); + + +-- +-- Data for Name: repair_templates; Type: TABLE DATA; Schema: Owner: postgres +-- + + + +-- +-- Data for Name: role_permission_mapping; Type: TABLE DATA; Schema: Owner: postgres +-- + +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (7, 19); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (7, 20); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (7, 21); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (7, 22); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (7, 23); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (7, 24); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (7, 25); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (7, 26); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (7, 27); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (7, 28); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (7, 29); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (7, 30); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (8, 23); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (8, 24); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (8, 25); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (8, 26); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (8, 27); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (8, 28); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (8, 29); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (10, 23); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (10, 25); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (10, 26); +INSERT INTO role_permission_mapping (role_id, permission_id) VALUES (10, 28); + + +-- +-- Data for Name: roles; Type: TABLE DATA; Schema: Owner: postgres +-- + +INSERT INTO roles (id, role_name, role_key, description, is_system_role, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (7, '管理员', 'admin', '拥有所有权限', true, '2025-12-14 07:33:23.611365+00', '2025-12-14 07:33:23.611365+00'); +INSERT INTO roles (id, role_name, role_key, description, is_system_role, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (8, '操作员', 'operator', '除系统管理外的操作权限', true, '2025-12-14 07:33:23.653257+00', '2025-12-14 07:33:23.653257+00'); +INSERT INTO roles (id, role_name, role_key, description, is_system_role, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (10, '观察员', 'observer', '基于操作员的只读子集', true, '2025-12-14 07:34:28.548724+00', '2025-12-14 07:34:28.548724+00'); + + +-- +-- Data for Name: system_logs; Type: TABLE DATA; Schema: Owner: postgres +-- + + + +-- +-- Data for Name: user_cluster_mapping; Type: TABLE DATA; Schema: Owner: postgres +-- + + + +-- +-- Data for Name: user_role_mapping; Type: TABLE DATA; Schema: Owner: postgres +-- + +INSERT INTO user_role_mapping (user_id, role_id) VALUES (4, 7); +INSERT INTO user_role_mapping (user_id, role_id) VALUES (3, 7); + + +-- +-- Data for Name: users; Type: TABLE DATA; Schema: Owner: postgres +-- + +INSERT INTO users (id, username, email, password_hash, full_name, is_active, last_login, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (4, 'bdmin', 'bdmin@qq.com', '$2b$12$.jKVn3UqH/w0Ajdi01aqY.K70z8QEtLlgL45u883hKp2sWREYG4Om', 'bdmin', true, '2025-12-12 07:47:22.734564+00', '2025-12-12 07:15:29.72108+00', '2025-12-12 07:47:22.734564+00'); +INSERT INTO users (id, username, email, password_hash, full_name, is_active, last_login, created_at, updated_at) OVERRIDING SYSTEM VALUE VALUES (3, 'admin', 'admin@qq.com', '$2b$12$F85LDEh5BP3G9VY9q/ALh.YpRNn.ob5fZM3fcfu.8G/B/WNgeBZPS', 'admin', true, '2025-12-12 07:47:31.178442+00', '2025-12-12 06:58:05.785083+00', '2025-12-12 07:47:31.178442+00'); + + +-- +-- Name: app_configurations_id_seq; Type: SEQUENCE SET; Schema: Owner: postgres +-- + +SELECT pg_catalog.setval('app_configurations_id_seq', 9, true); + + +-- +-- Name: audit_logs_id_seq; Type: SEQUENCE SET; Schema: Owner: postgres +-- + +SELECT pg_catalog.setval('audit_logs_id_seq', 1, false); + + +-- +-- Name: clusters_id_seq; Type: SEQUENCE SET; Schema: Owner: postgres +-- + +SELECT pg_catalog.setval('clusters_id_seq', 2, true); + + +-- +-- Name: exec_logs_id_seq; Type: SEQUENCE SET; Schema: Owner: postgres +-- + +SELECT pg_catalog.setval('exec_logs_id_seq', 1, false); + + +-- +-- Name: nodes_id_seq; Type: SEQUENCE SET; Schema: Owner: postgres +-- + +SELECT pg_catalog.setval('nodes_id_seq', 1, false); + + +-- +-- Name: permissions_id_seq; Type: SEQUENCE SET; Schema: Owner: postgres +-- + +SELECT pg_catalog.setval('permissions_id_seq', 30, true); + + +-- +-- Name: repair_templates_id_seq; Type: SEQUENCE SET; Schema: Owner: postgres +-- + +SELECT pg_catalog.setval('repair_templates_id_seq', 1, false); + + +-- +-- Name: roles_id_seq; Type: SEQUENCE SET; Schema: Owner: postgres +-- + +SELECT pg_catalog.setval('roles_id_seq', 10, true); + + +-- +-- Name: system_logs_id_seq; Type: SEQUENCE SET; Schema: Owner: postgres +-- + +SELECT pg_catalog.setval('system_logs_id_seq', 1, false); + + +-- +-- Name: user_cluster_mapping_id_seq; Type: SEQUENCE SET; Schema: Owner: postgres +-- + +SELECT pg_catalog.setval('user_cluster_mapping_id_seq', 2, true); + + +-- +-- Name: users_id_seq; Type: SEQUENCE SET; Schema: Owner: postgres +-- + +SELECT pg_catalog.setval('users_id_seq', 4, true); + + +-- +-- Name: app_configurations app_configurations_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY app_configurations + ADD CONSTRAINT app_configurations_pkey PRIMARY KEY (id); + + +-- +-- Name: audit_logs audit_logs_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY audit_logs + ADD CONSTRAINT audit_logs_pkey PRIMARY KEY (id); + + +-- +-- Name: clusters clusters_name_key; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY clusters + ADD CONSTRAINT clusters_name_key UNIQUE (name); + + +-- +-- Name: clusters clusters_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY clusters + ADD CONSTRAINT clusters_pkey PRIMARY KEY (id); + + +-- +-- Name: clusters clusters_uuid_key; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY clusters + ADD CONSTRAINT clusters_uuid_key UNIQUE (uuid); + + +-- +-- Name: exec_logs exec_logs_exec_id_key; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY exec_logs + ADD CONSTRAINT exec_logs_exec_id_key UNIQUE (exec_id); + + +-- +-- Name: exec_logs exec_logs_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY exec_logs + ADD CONSTRAINT exec_logs_pkey PRIMARY KEY (id); + + +-- +-- Name: nodes nodes_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY nodes + ADD CONSTRAINT nodes_pkey PRIMARY KEY (id); + + +-- +-- Name: nodes nodes_uuid_key; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY nodes + ADD CONSTRAINT nodes_uuid_key UNIQUE (uuid); + + +-- +-- Name: permissions permissions_permission_key_key; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY permissions + ADD CONSTRAINT permissions_permission_key_key UNIQUE (permission_key); + + +-- +-- Name: permissions permissions_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY permissions + ADD CONSTRAINT permissions_pkey PRIMARY KEY (id); + + +-- +-- Name: repair_templates repair_templates_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY repair_templates + ADD CONSTRAINT repair_templates_pkey PRIMARY KEY (id); + + +-- +-- Name: repair_templates repair_templates_template_name_key; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY repair_templates + ADD CONSTRAINT repair_templates_template_name_key UNIQUE (template_name); + + +-- +-- Name: role_permission_mapping role_permission_mapping_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY role_permission_mapping + ADD CONSTRAINT role_permission_mapping_pkey PRIMARY KEY (role_id, permission_id); + + +-- +-- Name: roles roles_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY roles + ADD CONSTRAINT roles_pkey PRIMARY KEY (id); + + +-- +-- Name: roles roles_role_key_key; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY roles + ADD CONSTRAINT roles_role_key_key UNIQUE (role_key); + + +-- +-- Name: system_logs system_logs_log_id_key; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY system_logs + ADD CONSTRAINT system_logs_log_id_key UNIQUE (log_id); + + +-- +-- Name: system_logs system_logs_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY system_logs + ADD CONSTRAINT system_logs_pkey PRIMARY KEY (id); + + +-- +-- Name: app_configurations uk_app_config; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY app_configurations + ADD CONSTRAINT uk_app_config UNIQUE (config_type, config_key); + + +-- +-- Name: user_cluster_mapping uk_user_cluster; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY user_cluster_mapping + ADD CONSTRAINT uk_user_cluster UNIQUE (user_id, cluster_id); + + +-- +-- Name: user_cluster_mapping user_cluster_mapping_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY user_cluster_mapping + ADD CONSTRAINT user_cluster_mapping_pkey PRIMARY KEY (id); + + +-- +-- Name: user_role_mapping user_role_mapping_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY user_role_mapping + ADD CONSTRAINT user_role_mapping_pkey PRIMARY KEY (user_id, role_id); + + +-- +-- Name: users users_email_key; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY users + ADD CONSTRAINT users_email_key UNIQUE (email); + + +-- +-- Name: users users_pkey; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY users + ADD CONSTRAINT users_pkey PRIMARY KEY (id); + + +-- +-- Name: users users_username_key; Type: CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY users + ADD CONSTRAINT users_username_key UNIQUE (username); + + +-- +-- Name: idx_app_config_enabled; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_app_config_enabled ON app_configurations USING btree (is_enabled); + + +-- +-- Name: idx_audit_logs_action; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_audit_logs_action ON audit_logs USING btree (action); + + +-- +-- Name: idx_audit_logs_cluster_id; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_audit_logs_cluster_id ON audit_logs USING btree (cluster_id); + + +-- +-- Name: idx_audit_logs_created_at; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_audit_logs_created_at ON audit_logs USING btree (created_at); + + +-- +-- Name: idx_audit_logs_role_id; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_audit_logs_role_id ON audit_logs USING btree (role_id); + + +-- +-- Name: idx_audit_logs_user_id; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_audit_logs_user_id ON audit_logs USING btree (user_id); + + +-- +-- Name: idx_exec_logs_end_time; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_exec_logs_end_time ON exec_logs USING btree (end_time); + + +-- +-- Name: idx_exec_logs_fault_id; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_exec_logs_fault_id ON exec_logs USING btree (fault_id); + + +-- +-- Name: idx_exec_logs_start_time; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_exec_logs_start_time ON exec_logs USING btree (start_time); + + +-- +-- Name: idx_exec_logs_status; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_exec_logs_status ON exec_logs USING btree (execution_status); + + +-- +-- Name: idx_nodes_cluster_id; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_nodes_cluster_id ON nodes USING btree (cluster_id); + + +-- +-- Name: idx_nodes_ip_address; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_nodes_ip_address ON nodes USING btree (ip_address); + + +-- +-- Name: idx_nodes_last_heartbeat; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_nodes_last_heartbeat ON nodes USING btree (last_heartbeat); + + +-- +-- Name: idx_nodes_status; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_nodes_status ON nodes USING btree (status); + + +-- +-- Name: idx_repair_templates_fault_type; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_repair_templates_fault_type ON repair_templates USING btree (fault_type); + + +-- +-- Name: idx_system_logs_cluster_id; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_system_logs_cluster_id ON system_logs USING btree (cluster_id); + + +-- +-- Name: idx_system_logs_fault_id; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_system_logs_fault_id ON system_logs USING btree (fault_id); + + +-- +-- Name: idx_system_logs_level; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_system_logs_level ON system_logs USING btree (log_level); + + +-- +-- Name: idx_system_logs_processed; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_system_logs_processed ON system_logs USING btree (processed); + + +-- +-- Name: idx_system_logs_timestamp; Type: INDEX; Schema: Owner: postgres +-- + +CREATE INDEX idx_system_logs_timestamp ON system_logs USING btree ("timestamp"); + + +-- +-- Name: uk_cluster_hostname; Type: INDEX; Schema: Owner: postgres +-- + +CREATE UNIQUE INDEX uk_cluster_hostname ON nodes USING btree (cluster_id, hostname); + + +-- +-- Name: audit_logs audit_logs_cluster_id_fkey; Type: FK CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY audit_logs + ADD CONSTRAINT audit_logs_cluster_id_fkey FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: audit_logs audit_logs_role_id_fkey; Type: FK CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY audit_logs + ADD CONSTRAINT audit_logs_role_id_fkey FOREIGN KEY (role_id) REFERENCES roles(id) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: audit_logs audit_logs_user_id_fkey; Type: FK CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY audit_logs + ADD CONSTRAINT audit_logs_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: nodes nodes_cluster_id_fkey; Type: FK CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY nodes + ADD CONSTRAINT nodes_cluster_id_fkey FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: role_permission_mapping role_permission_mapping_permission_id_fkey; Type: FK CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY role_permission_mapping + ADD CONSTRAINT role_permission_mapping_permission_id_fkey FOREIGN KEY (permission_id) REFERENCES permissions(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: role_permission_mapping role_permission_mapping_role_id_fkey; Type: FK CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY role_permission_mapping + ADD CONSTRAINT role_permission_mapping_role_id_fkey FOREIGN KEY (role_id) REFERENCES roles(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: system_logs system_logs_cluster_id_fkey; Type: FK CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY system_logs + ADD CONSTRAINT system_logs_cluster_id_fkey FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: user_cluster_mapping user_cluster_mapping_cluster_id_fkey; Type: FK CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY user_cluster_mapping + ADD CONSTRAINT user_cluster_mapping_cluster_id_fkey FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: user_cluster_mapping user_cluster_mapping_role_id_fkey; Type: FK CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY user_cluster_mapping + ADD CONSTRAINT user_cluster_mapping_role_id_fkey FOREIGN KEY (role_id) REFERENCES roles(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: user_cluster_mapping user_cluster_mapping_user_id_fkey; Type: FK CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY user_cluster_mapping + ADD CONSTRAINT user_cluster_mapping_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: user_role_mapping user_role_mapping_role_id_fkey; Type: FK CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY user_role_mapping + ADD CONSTRAINT user_role_mapping_role_id_fkey FOREIGN KEY (role_id) REFERENCES roles(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: user_role_mapping user_role_mapping_user_id_fkey; Type: FK CONSTRAINT; Schema: Owner: postgres +-- + +ALTER TABLE ONLY user_role_mapping + ADD CONSTRAINT user_role_mapping_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: SCHEMA Type: ACL; Schema: -; Owner: pg_database_owner +-- + +GRANT USAGE ON SCHEMA TO echo; + + +-- +-- Name: TABLE app_configurations; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE app_configurations TO echo; + + +-- +-- Name: SEQUENCE app_configurations_id_seq; Type: ACL; Schema: Owner: postgres +-- + +GRANT ALL ON SEQUENCE app_configurations_id_seq TO echo; + + +-- +-- Name: TABLE audit_logs; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE audit_logs TO echo; + + +-- +-- Name: SEQUENCE audit_logs_id_seq; Type: ACL; Schema: Owner: postgres +-- + +GRANT ALL ON SEQUENCE audit_logs_id_seq TO echo; + + +-- +-- Name: TABLE clusters; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE clusters TO echo; + + +-- +-- Name: SEQUENCE clusters_id_seq; Type: ACL; Schema: Owner: postgres +-- + +GRANT ALL ON SEQUENCE clusters_id_seq TO echo; + + +-- +-- Name: TABLE exec_logs; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE exec_logs TO echo; + + +-- +-- Name: SEQUENCE exec_logs_id_seq; Type: ACL; Schema: Owner: postgres +-- + +GRANT ALL ON SEQUENCE exec_logs_id_seq TO echo; + + +-- +-- Name: TABLE nodes; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE nodes TO echo; + + +-- +-- Name: SEQUENCE nodes_id_seq; Type: ACL; Schema: Owner: postgres +-- + +GRANT ALL ON SEQUENCE nodes_id_seq TO echo; + + +-- +-- Name: TABLE permissions; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE permissions TO echo; + + +-- +-- Name: SEQUENCE permissions_id_seq; Type: ACL; Schema: Owner: postgres +-- + +GRANT ALL ON SEQUENCE permissions_id_seq TO echo; + + +-- +-- Name: TABLE repair_templates; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE repair_templates TO echo; + + +-- +-- Name: SEQUENCE repair_templates_id_seq; Type: ACL; Schema: Owner: postgres +-- + +GRANT ALL ON SEQUENCE repair_templates_id_seq TO echo; + + +-- +-- Name: TABLE role_permission_mapping; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE role_permission_mapping TO echo; + + +-- +-- Name: TABLE roles; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE roles TO echo; + + +-- +-- Name: SEQUENCE roles_id_seq; Type: ACL; Schema: Owner: postgres +-- + +GRANT ALL ON SEQUENCE roles_id_seq TO echo; + + +-- +-- Name: TABLE system_logs; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE system_logs TO echo; + + +-- +-- Name: SEQUENCE system_logs_id_seq; Type: ACL; Schema: Owner: postgres +-- + +GRANT ALL ON SEQUENCE system_logs_id_seq TO echo; + + +-- +-- Name: TABLE user_cluster_mapping; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE user_cluster_mapping TO echo; + + +-- +-- Name: SEQUENCE user_cluster_mapping_id_seq; Type: ACL; Schema: Owner: postgres +-- + +GRANT ALL ON SEQUENCE user_cluster_mapping_id_seq TO echo; + + +-- +-- Name: TABLE user_role_mapping; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE user_role_mapping TO echo; + + +-- +-- Name: TABLE users; Type: ACL; Schema: Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE users TO echo; + + +-- +-- Name: SEQUENCE users_id_seq; Type: ACL; Schema: Owner: postgres +-- + +GRANT ALL ON SEQUENCE users_id_seq TO echo; + + +-- +-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: Owner: postgres +-- + +ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA GRANT ALL ON SEQUENCES TO echo; + + +-- +-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: Owner: postgres +-- + +ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA GRANT SELECT,INSERT,DELETE,UPDATE ON TABLES TO echo; + + +-- +-- PostgreSQL database dump complete +-- + +\unrestrict Uu5RUeD7W50Ldfv5i1NSxXc0jR7r8L5p2hetPJEHpgrfI5ZxVEjRijvDSKNmtSn +