Files
Agent-Tools/crates/agentdock-store/src/schema.rs
T

34 lines
1.1 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! schema 定义与迁移骨架(Wave 0)
//!
//! 迁移采用顺序数组:每个元素是一段幂等 SQL(CREATE TABLE IF NOT EXISTS)。
//! 后续波次新增表时在 `MIGRATIONS` 尾部追加并提升 `SCHEMA_VERSION`。
/// 当前 schema 版本
pub const SCHEMA_VERSION: i64 = 1;
/// 迁移列表(按顺序执行,均需幂等)
pub const MIGRATIONS: [&str; 3] = [
// 迁移 1:schema 版本表
"CREATE TABLE IF NOT EXISTS schema_version (
version INTEGER NOT NULL,
applied_at TEXT NOT NULL DEFAULT (datetime('now'))
);",
// 迁移 2:已安装 CLI 记录
"CREATE TABLE IF NOT EXISTS installed_clis (
cli_id TEXT PRIMARY KEY,
name_zh TEXT NOT NULL,
version TEXT,
install_channel TEXT,
detected_at TEXT
);",
// 迁移 3:诊断历史
"CREATE TABLE IF NOT EXISTS diagnostic_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
cli_id TEXT NOT NULL,
rule_id TEXT NOT NULL,
severity TEXT NOT NULL,
message_zh TEXT NOT NULL,
created_at TEXT NOT NULL DEFAULT (datetime('now'))
);",
];