migrate from v1.2
This commit is contained in:
parent
f479c55501
commit
04057aa94a
|
@ -11,11 +11,21 @@ module.exports.create = function (opts) {
|
||||||
var db = require(opts.filepath);
|
var db = require(opts.filepath);
|
||||||
var stat = require('fs').statSync(opts.filepath);
|
var stat = require('fs').statSync(opts.filepath);
|
||||||
var crypto = require('crypto');
|
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) {
|
if (!ns.id) {
|
||||||
ns.id = crypto.randomBytes(16).toString('hex');
|
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) {
|
db.zones.forEach(function (zone) {
|
||||||
if (!zone.name) {
|
if (!zone.name) {
|
||||||
zone.name = zone.id;
|
zone.name = zone.id;
|
||||||
|
@ -32,6 +42,11 @@ module.exports.create = function (opts) {
|
||||||
record.id = crypto.randomBytes(16).toString('hex');
|
record.id = crypto.randomBytes(16).toString('hex');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
require('fs').writeFileSync(opts.filepath, JSON.stringify(db, null, 2));
|
||||||
|
//
|
||||||
|
// End Migration
|
||||||
|
//
|
||||||
|
|
||||||
db.save = function (cb) {
|
db.save = function (cb) {
|
||||||
if (db.save._saving) {
|
if (db.save._saving) {
|
||||||
console.log('make pending');
|
console.log('make pending');
|
||||||
|
@ -55,7 +70,6 @@ module.exports.create = function (opts) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
db.save._pending = [];
|
db.save._pending = [];
|
||||||
require('fs').writeFileSync(opts.filepath, JSON.stringify(db, null, 2));
|
|
||||||
|
|
||||||
engine.primaryNameservers = db.primaryNameservers;
|
engine.primaryNameservers = db.primaryNameservers;
|
||||||
engine.zoneToSoa = function (domain) {
|
engine.zoneToSoa = function (domain) {
|
||||||
|
|
Loading…
Reference in New Issue