()
| 205 | |
| 206 | // 0.10.0重构,重命名字段,统一使用小峰驼 |
| 207 | function renameField() { |
| 208 | db.version(16) |
| 209 | .stores({ |
| 210 | scripts: |
| 211 | "++id,&uuid,name,namespace,author,originDomain,subscribeUrl,type,sort,status," + |
| 212 | "runStatus,createtime,updatetime,checktime", |
| 213 | logger: "++id,level,createtime", |
| 214 | // export: "++id,&scriptId", |
| 215 | }) |
| 216 | .upgrade(async (tx) => { |
| 217 | await tx.table("export").clear(); |
| 218 | return tx |
| 219 | .table("scripts") |
| 220 | .toCollection() |
| 221 | .modify((script: { [key: string]: any }) => { |
| 222 | if (script.origin_domain) { |
| 223 | script.originDomain = script.origin_domain; |
| 224 | } |
| 225 | if (script.checkupdate_url) { |
| 226 | script.checkUpdateUrl = script.checkupdate_url; |
| 227 | } |
| 228 | if (script.download_url) { |
| 229 | script.downloadUrl = script.download_url; |
| 230 | } |
| 231 | }); |
| 232 | }); |
| 233 | db.version(17).stores({ |
| 234 | // export是0.10.x时的兼容性处理 |
| 235 | export: "++id,&scriptId", |
| 236 | }); |
| 237 | // 将脚本数据迁移到chrome.storage |
| 238 | db.version(18).upgrade(() => { |
| 239 | migrateToChromeStorage(); |
| 240 | }); |
| 241 | |
| 242 | return db.open(); |
| 243 | } |
| 244 | |
| 245 | // 迁移chrome.storage的数据 |
| 246 | export function migrateChromeStorage() { |
no test coverage detected