v0.7.0-alpha.0
Home / Documentation / Migration

Migration

Move earlier data logically into a new modern BsonLite directory while retaining the original store.

Upgrade an earlier encrypted database

The modern engine must not open old 4.0 data files directly. Stop applications using the store. Keep its original directory, protected vault and an encrypted backup. Work under the Windows account that can open the old store.

Install the previous package under a separate name:

powershell
npm install bsonlite-previous@npm:bsonlite-sdk@0.6.0-rc.3

Put the validated current BsonLite.cjs beside this script:

javascript
const previous = require('bsonlite-previous');
const modern = require('./BsonLite.cjs');

async function main() {
  await previous.backup({
    directory: './Database',
    file: './before-upgrade.bslbackup',
    password: process.env.BSONLITE_BACKUP_PASSWORD
  });
  const result = await modern.upgrade({
    sourceSDK: previous,
    sourceDirectory: './Database',
    directory: './Database9'
  });
  console.log(result);
}
main().catch(error => {
  console.error(error.code, error.message);
  process.exitCode = 1;
});

Set your own backup password in BSONLITE_BACKUP_PASSWORD. The destination must not exist or overlap the source. The sourceSDK option is the API's existing property name.

Verify the new destination

The upgrader converts BSON across driver majors, recreates supported indexes, validators and views, and verifies document counts and digests. Failed or interrupted destinations stay marked incomplete; the original records are retained.

Non-simple collations require tested, explicit allowCollationUpgrade: true because ICU comparison rules differ. After checking your application's data, connect to the destination:

javascript
await BsonLite.connect({ directory: './Database9' });

Create a new encrypted backup. Keep the original database, vault and backup until application verification is complete. A physical backup still requires its matching engine profile.

Earlier non-native formats

Use the previous version's documented migration path first. Changing metadata, copying data files or renaming a version does not convert the storage format.

Maintained core upgrade guide · Backup and restore

BsonLite 0.7.0-alpha.0 · Downloads · BsonLite Console · Support development