Skip migration if its completed

This commit is contained in:
Raven Scott
2026-05-28 00:26:32 -04:00
parent 7b1983cd81
commit 5559c9096d
5 changed files with 100 additions and 10 deletions
+11 -3
View File
@@ -636,10 +636,18 @@ See [test-scripts/README.md](../test-scripts/README.md) for more information abo
7. **Schema migrations**: When bumping `version` in `config.json`, P2NS automatically copies all collection data from the previous version's Hypercore into the new one on startup. A manifest at `plugin-sites/{domain}/db/.p2ns-db-version.json` tracks the last migrated version.
- Update `version` in `config.json` (and schema in `hyperdb` if needed)
- Restart P2NS — local data is migrated automatically
- Bump `version` in `config.json` and set migration flags under `hyperdb`:
```json
"hyperdb": {
"previousVersion": "1.2.2",
"migrated": false,
...
}
```
- Restart P2NS — data is copied once from `previousVersion` to the new core, then `migrated` is set to `true` (`previousVersion` stays in config for reference)
- On the next bump, update `previousVersion` to the version you are leaving (e.g. `1.4.1` → `1.4.2` with `"previousVersion": "1.4.1"`) and set `migrated` back to `false`
- Coordinate the same version bump with all peers so replication uses the same core topic
- If upgrading from before auto-migration and data appears missing, add the old version to `hyperdb.versionHistory` in `config.json` once (e.g. `"versionHistory": ["1.2.1"]`) and restart
- If upgrading from before auto-migration and data appears missing, add the old version to `hyperdb.versionHistory` once (e.g. `"versionHistory": ["1.2.1"]`) and `"migrated": false`
## Reference