Migrations and encryption
Local Barq files can use schema versions, migrations, compaction, and encryption keys.
Local Migrations
Section titled “Local Migrations”When changing a local schema, bump schemaVersion and provide onMigration if old data needs to be moved.
const barq = await Barq.open({ schema: [Task], schemaVersion: 2, onMigration(oldBarq, newBarq) { // Move old data into the new schema here. },});onMigration is not used together with sync.
Local Encryption
Section titled “Local Encryption”Pass a 64-byte key to encrypt a local database file.
const key = crypto.getRandomValues(new Uint8Array(64));
const barq = await Barq.open({ path: 'secure.barq', schema: [Task], encryptionKey: key,});Store encryption keys outside the database file.
Server-side Tenant Encryption
Section titled “Server-side Tenant Encryption”The sync server can derive per-tenant database keys from a master secret when run with --tenant-encryption-master-key.