first commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
const Database = require('better-sqlite3');
|
||||
const path = require('path');
|
||||
|
||||
const dbPath = path.join(__dirname, '../data/certificates.db');
|
||||
const db = new Database(dbPath);
|
||||
|
||||
try {
|
||||
// 检查字段是否存在
|
||||
const tableInfo = db.prepare("PRAGMA table_info(certificates)").all();
|
||||
const hasDnsMode = tableInfo.some(col => col.name === 'dns_mode');
|
||||
|
||||
if (!hasDnsMode) {
|
||||
db.exec(`ALTER TABLE certificates ADD COLUMN dns_mode TEXT;`);
|
||||
console.log('✓ 已添加 dns_mode 字段');
|
||||
} else {
|
||||
console.log('✓ dns_mode 字段已存在');
|
||||
}
|
||||
|
||||
console.log('数据库迁移完成');
|
||||
} catch (error) {
|
||||
console.error('迁移失败:', error.message);
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
Reference in New Issue
Block a user