forked from snxraven/p2ns
automatic db migrations on version bump
This commit is contained in:
@@ -632,13 +632,14 @@ See [test-scripts/README.md](../test-scripts/README.md) for more information abo
|
||||
|
||||
5. **Check status**: Use `sdk.db.replication.getStatus()` to monitor replication health.
|
||||
|
||||
6. **Version bumping**: Bump `version` in config.json when making incompatible schema changes (e.g., removing indexes, changing key fields). This creates a new database topic.
|
||||
6. **Version bumping**: Bump `version` in config.json when making incompatible schema changes (e.g., removing indexes, changing key fields). This creates a new replicated core topic; P2NS migrates local data from the previous version on startup.
|
||||
|
||||
7. **Schema migrations**: When bumping version for schema changes:
|
||||
- Update `version` in `config.json`
|
||||
- Delete local database: `rm -rf plugin-sites/{domain}/db`
|
||||
- Restart P2NS
|
||||
- Coordinate version update with all peers
|
||||
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
|
||||
- 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
|
||||
|
||||
## Reference
|
||||
|
||||
|
||||
Reference in New Issue
Block a user