diff --git a/lib/store.json.js b/lib/store.json.js index 5c33496..7c532f3 100644 --- a/lib/store.json.js +++ b/lib/store.json.js @@ -11,11 +11,21 @@ module.exports.create = function (opts) { var db = require(opts.filepath); var stat = require('fs').statSync(opts.filepath); var crypto = require('crypto'); - db.primaryNameservers.forEach(function (ns) { + // + // Manual Migration + // + db.primaryNameservers.forEach(function (ns, i, arr) { + if ('string' === typeof ns) { + arr[i] = { name: ns }; + } if (!ns.id) { ns.id = crypto.randomBytes(16).toString('hex'); } }); + db.zones = db.zones || []; + if (db.domains) { + db.zones = db.zones.concat(db.domains); + } db.zones.forEach(function (zone) { if (!zone.name) { zone.name = zone.id; @@ -32,6 +42,11 @@ module.exports.create = function (opts) { record.id = crypto.randomBytes(16).toString('hex'); } }); + require('fs').writeFileSync(opts.filepath, JSON.stringify(db, null, 2)); + // + // End Migration + // + db.save = function (cb) { if (db.save._saving) { console.log('make pending'); @@ -55,7 +70,6 @@ module.exports.create = function (opts) { }); }; db.save._pending = []; - require('fs').writeFileSync(opts.filepath, JSON.stringify(db, null, 2)); engine.primaryNameservers = db.primaryNameservers; engine.zoneToSoa = function (domain) {