{"id":22746418,"url":"https://github.com/zhujiaming/node-sqlite-updater","last_synced_at":"2025-04-14T10:21:56.621Z","repository":{"id":120627285,"uuid":"384096322","full_name":"zhujiaming/node-sqlite-updater","owner":"zhujiaming","description":"nodejs-sqlite3 数据库版本管理与升级","archived":false,"fork":false,"pushed_at":"2021-07-19T01:35:56.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-24T07:13:17.211Z","etag":null,"topics":["database","nodejs","sqlite3","typeorm","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhujiaming.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-08T11:07:08.000Z","updated_at":"2023-02-08T08:57:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"55d1f207-7543-498f-b79b-6e01e6bb436d","html_url":"https://github.com/zhujiaming/node-sqlite-updater","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"9a389aba2a22037227c3278f210c3fa4cdf6ad9f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhujiaming%2Fnode-sqlite-updater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhujiaming%2Fnode-sqlite-updater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhujiaming%2Fnode-sqlite-updater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhujiaming%2Fnode-sqlite-updater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhujiaming","download_url":"https://codeload.github.com/zhujiaming/node-sqlite-updater/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860044,"owners_count":21173352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","nodejs","sqlite3","typeorm","typescript"],"created_at":"2024-12-11T02:13:15.738Z","updated_at":"2025-04-14T10:21:56.615Z","avatar_url":"https://github.com/zhujiaming.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### node-sqlite-updater\n\n\u003e 基于nodejs的客户端或服务端使用sqlite3时，对数据库文件进行版本管理升级的辅助工具库，对Electron+sqlite3+typeorm应用友好。\n\n### 接入\n\n```powershell\nnpm i node-sqlite-updater\n```\n\n### 使用\n\n```javascript\nconst dbFile = path.join(\"\",'test.db')//目标数据库文件\nconst DB_VERSION = 1 //当前应用对应的当前数据库文件版本，每次+1会触发升级，默认从1开始。\nconst dbupgradeImpl = new DbUpgradeImpl() //数据库升级的具体内容是抽象接口，交给业务实现，参考./example/upgrade-impl.ts。\n\nfunction beforInitDB() {\n            let dbUpdater = new DbUpdater({\n                vercode: 1, \n                database: dbFile,\n                logging: true, //是否打印日志\n                upgradeImpl: dbupgradeImpl\n            });\n\n            dbUpdater\n                .init()\n                .then(res =\u003e {\n                    console.log('db update res',res)\n                    initDB() //成功后继续正常db init\n                }).catch(e =\u003e {\n                    console.error('db update err', e)\n                });\n        }\n\nfunction initDB(){\n    // custom init db\n}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhujiaming%2Fnode-sqlite-updater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhujiaming%2Fnode-sqlite-updater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhujiaming%2Fnode-sqlite-updater/lists"}