( sessionId: string, forceRepair = false, runtime?: RuntimeIdentity )
| 92 | * @param forceRepair 是否强制修复(即使版本号已是最新也重新执行迁移脚本) |
| 93 | */ |
| 94 | export function openDatabaseWithMigration( |
| 95 | sessionId: string, |
| 96 | forceRepair = false, |
| 97 | runtime?: RuntimeIdentity |
| 98 | ): Database.Database | null { |
| 99 | const dbPath = getDbPath(sessionId) |
| 100 | if (!fs.existsSync(dbPath)) { |
| 101 | return null |
| 102 | } |
| 103 | |
| 104 | const db = new Database(dbPath) |
| 105 | db.pragma('journal_mode = WAL') |
| 106 | |
| 107 | // 执行迁移 |
| 108 | migrateDatabase(db, forceRepair, { pathProvider: getPathProvider(), runtime }) |
| 109 | |
| 110 | return db |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * 导入解析后的数据到数据库 |
no test coverage detected