1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-20 23:30:05 +02:00
Files
joplin/packages/lib/migrations/40.ts

31 lines
1020 B
TypeScript
Raw Normal View History

2021-06-25 14:51:36 +01:00
import JoplinDatabase from '../JoplinDatabase';
import { MigrationScript } from '../models/Migration';
import Setting from '../models/Setting';
import { SyncTargetInfo } from '../services/synchronizer/syncTargetInfoUtils';
const script: MigrationScript = {
exec: async function(db: JoplinDatabase): Promise<void> {
const masterKeys = await db.selectAll('SELECT * FROM master_keys');
const masterKeyMap: Record<string, any> = {};
for (const mk of masterKeys) masterKeyMap[mk.id] = mk;
const syncInfo: SyncTargetInfo = {
2021-06-26 22:13:38 +01:00
// When we first setup the local sync target info, we don't know
// what's on the remote one, so we set it to 0. During sync, the
// version from remote will be fetched.
version: 0,
2021-06-25 14:51:36 +01:00
e2ee: Setting.valueNoThrow('encryption.enabled', false),
masterKeys: masterKeyMap,
activeMasterKeyId: Setting.valueNoThrow('encryption.activeMasterKeyId', ''),
updatedTime: Date.now(),
};
Setting.setValue('sync.info', JSON.stringify(syncInfo));
},
};
export default script;