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

Commit

Permalink
feat: add realm migration from v1 to v2 (#1274)
Browse files Browse the repository at this point in the history
  • Loading branch information
laumair authored and cvarley100 committed Apr 8, 2019
1 parent 649170c commit bcf45ea
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
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 };

0 comments on commit bcf45ea

Please sign in to comment.