Merge pull request #3904 from MetaMask/migrations-template
meta - create a migration templatefeature/default_network_editable
commit
b8efe120a9
@ -0,0 +1,29 @@ |
||||
// next version number
|
||||
const version = 0 |
||||
|
||||
/* |
||||
|
||||
description of migration and what it does |
||||
|
||||
*/ |
||||
|
||||
const clone = require('clone') |
||||
|
||||
module.exports = { |
||||
version, |
||||
|
||||
migrate: async function (originalVersionedData) { |
||||
const versionedData = clone(originalVersionedData) |
||||
versionedData.meta.version = version |
||||
const state = versionedData.data |
||||
const newState = transformState(state) |
||||
versionedData.data = newState |
||||
return versionedData |
||||
}, |
||||
} |
||||
|
||||
function transformState (state) { |
||||
const newState = state |
||||
// transform state here
|
||||
return newState |
||||
} |
@ -0,0 +1,17 @@ |
||||
const assert = require('assert') |
||||
const migrationTemplate = require('../../../app/scripts/migrations/template') |
||||
const properTime = (new Date()).getTime() |
||||
const storage = { |
||||
meta: {}, |
||||
data: {}, |
||||
} |
||||
|
||||
describe('storage is migrated successfully', () => { |
||||
it('should work', (done) => { |
||||
migrationTemplate.migrate(storage) |
||||
.then((migratedData) => { |
||||
assert.equal(migratedData.meta.version, 0) |
||||
done() |
||||
}).catch(done) |
||||
}) |
||||
}) |
Loading…
Reference in new issue