Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Add realm migration from v1 to v2 #1274

Merged
merged 1 commit into from Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/shared/schemas/index.js
@@ -1,6 +1,7 @@
/* global Electron */
import v0Schema from './v0';
import v1Schema, { migration as v1Migration } from './v1';
import v2Schema, { migration as v2Migration } from './v2';
import { __MOBILE__, __TEST__, __DEV__ } from '../config';

const STORAGE_PATH =
Expand Down Expand Up @@ -32,6 +33,12 @@ export default [
migration: v1Migration,
path: STORAGE_PATH,
},
{
schema: v2Schema,
schemaVersion: 2,
path: STORAGE_PATH,
migration: v2Migration,
},
];

export { v0Schema, v1Schema, STORAGE_PATH, getDeprecatedStoragePath };
30 changes: 30 additions & 0 deletions src/shared/schemas/v2/index.js
@@ -0,0 +1,30 @@
import merge from 'lodash/merge';
import map from 'lodash/map';
import defaultSchemas from '../default';

const migration = (_, newRealm) => {
const walletData = newRealm.objectForPrimaryKey('Wallet', 1);

// Bump wallet version.
walletData.version = 2;
};

export default map(defaultSchemas, (schema) => {
if (schema.name === 'WalletSettings') {
return merge({}, schema, {
properties: {
/**
* Determines if deep linking is enabled
*/
deepLinking: {
type: 'bool',
default: false,
},
},
});
}

return schema;
});

export { migration };