This commit is contained in:
Baobhan Sith
2025-04-15 08:34:03 +08:00
parent b58f5da52b
commit 4ec2ec869f
2 changed files with 11 additions and 1 deletions
+10 -1
View File
@@ -32,7 +32,7 @@ CREATE TABLE IF NOT EXISTS connections (
);
`;
// 新增:创建 proxies 表的 SQL
// 新增:创建 proxies 表的 SQL (与文档同步)
const createProxiesTableSQL = `
CREATE TABLE IF NOT EXISTS proxies (
id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -41,7 +41,10 @@ CREATE TABLE IF NOT EXISTS proxies (
host TEXT NOT NULL,
port INTEGER NOT NULL,
username TEXT NULL, -- 代理认证用户名 (可选)
auth_method TEXT NOT NULL DEFAULT 'none' CHECK(auth_method IN ('none', 'password', 'key')), -- 添加 auth_method
encrypted_password TEXT NULL, -- 加密存储的代理密码 (可选)
encrypted_private_key TEXT NULL, -- 添加 encrypted_private_key
encrypted_passphrase TEXT NULL, -- 添加 encrypted_passphrase
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL
);
@@ -171,6 +174,12 @@ export const runMigrations = async (db: Database): Promise<void> => {
});
});
// Add columns to proxies table if they don't exist (to match documentation)
await addColumnIfNotExists(db, 'proxies', 'auth_method', "TEXT NOT NULL DEFAULT 'none'");
await addColumnIfNotExists(db, 'proxies', 'encrypted_private_key', 'TEXT NULL');
await addColumnIfNotExists(db, 'proxies', 'encrypted_passphrase', 'TEXT NULL');
// 新增:创建 tags 表 (如果不存在)
await new Promise<void>((resolve, reject) => {
db.run(createTagsTableSQL, (err) => {