mysqlsyncr 1.0.82 → 1.0.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +315 -210
- package/dist/index.js +315 -211
- package/package.json +1 -1
- package/src/compare.js +1 -1
- package/src/differences.js +23 -19
- package/src/dump.js +0 -1
- package/src/index.js +42 -8
- package/ui/dist/spa/assets/{MainLayout-Cft1OeWe.js → MainLayout-CvQD3xKr.js} +1 -1
- package/ui/dist/spa/assets/{axios-CNk6rzlZ.js → axios-C0XcclIb.js} +1 -1
- package/ui/dist/spa/assets/index-CwWo8xmP.js +40 -0
- package/ui/dist/spa/index.html +1 -1
- package/ui/src/pages/MainComponent.vue +155 -18
- package/ui/dist/spa/assets/index-DomDZ6ci.js +0 -30
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,6 @@ var path = require('path');
|
|
|
8
8
|
var yargs = require('yargs');
|
|
9
9
|
var assert = require('assert');
|
|
10
10
|
var url = require('url');
|
|
11
|
-
require('module');
|
|
12
11
|
var fs$1 = require('fs/promises');
|
|
13
12
|
var express = require('express');
|
|
14
13
|
var http = require('http');
|
|
@@ -3191,7 +3190,14 @@ var findDifferences = function findDifferences(expected, current) {
|
|
|
3191
3190
|
_tableName = _Object$entries$_i[0],
|
|
3192
3191
|
contents = _Object$entries$_i[1];
|
|
3193
3192
|
//check if craete table matches from json, if so, we dont need to compare indexes, triggers, or fields
|
|
3194
|
-
|
|
3193
|
+
var columns = contents.columns,
|
|
3194
|
+
indexes = contents.indexes,
|
|
3195
|
+
triggers = contents.triggers;
|
|
3196
|
+
contents.createSQL;
|
|
3197
|
+
contents.name;
|
|
3198
|
+
contents.engine;
|
|
3199
|
+
contents.charset;
|
|
3200
|
+
contents.collate;
|
|
3195
3201
|
if (!current.tables[_tableName]) {
|
|
3196
3202
|
console.log('missing_table', contents);
|
|
3197
3203
|
differences.push({
|
|
@@ -3201,70 +3207,73 @@ var findDifferences = function findDifferences(expected, current) {
|
|
|
3201
3207
|
});
|
|
3202
3208
|
continue;
|
|
3203
3209
|
}
|
|
3204
|
-
|
|
3205
|
-
//verify triggers
|
|
3206
|
-
logger('Verifying triggers for table', _tableName);
|
|
3207
|
-
var _iterator = _createForOfIteratorHelper(triggers),
|
|
3208
|
-
_step;
|
|
3209
3210
|
try {
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
tableName: _tableName,
|
|
3220
|
-
trigger: trigger
|
|
3211
|
+
//verify triggers
|
|
3212
|
+
logger('Verifying triggers for table', _tableName);
|
|
3213
|
+
var _iterator = _createForOfIteratorHelper(triggers),
|
|
3214
|
+
_step;
|
|
3215
|
+
try {
|
|
3216
|
+
var _loop = function _loop() {
|
|
3217
|
+
var trigger = _step.value;
|
|
3218
|
+
var currentTrigger = current.tables[_tableName].triggers.find(function (t) {
|
|
3219
|
+
return t.Name === trigger.Name;
|
|
3221
3220
|
});
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
if (currentTrigger.Event !== trigger.Event || currentTrigger.Statement !== trigger.Statement) {
|
|
3225
|
-
logger('Mismatched trigger', {
|
|
3226
|
-
expected: trigger,
|
|
3227
|
-
current: currentTrigger
|
|
3228
|
-
});
|
|
3221
|
+
if (!currentTrigger) {
|
|
3222
|
+
logger('Missing trigger', trigger);
|
|
3229
3223
|
differences.push({
|
|
3230
|
-
type: '
|
|
3224
|
+
type: 'missing_trigger',
|
|
3231
3225
|
tableName: _tableName,
|
|
3232
3226
|
trigger: trigger
|
|
3233
3227
|
});
|
|
3228
|
+
} else {
|
|
3229
|
+
// Compare additional properties if needed
|
|
3230
|
+
if (currentTrigger.Event !== trigger.Event || currentTrigger.Statement !== trigger.Statement) {
|
|
3231
|
+
logger('Mismatched trigger', {
|
|
3232
|
+
expected: trigger,
|
|
3233
|
+
current: currentTrigger
|
|
3234
|
+
});
|
|
3235
|
+
differences.push({
|
|
3236
|
+
type: 'mismatched_trigger',
|
|
3237
|
+
tableName: _tableName,
|
|
3238
|
+
trigger: trigger
|
|
3239
|
+
});
|
|
3240
|
+
}
|
|
3234
3241
|
}
|
|
3242
|
+
};
|
|
3243
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
3244
|
+
_loop();
|
|
3235
3245
|
}
|
|
3236
|
-
}
|
|
3237
|
-
|
|
3238
|
-
|
|
3246
|
+
} catch (err) {
|
|
3247
|
+
_iterator.e(err);
|
|
3248
|
+
} finally {
|
|
3249
|
+
_iterator.f();
|
|
3239
3250
|
}
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
});
|
|
3251
|
+
var _iterator2 = _createForOfIteratorHelper(current.tables[_tableName].triggers),
|
|
3252
|
+
_step2;
|
|
3253
|
+
try {
|
|
3254
|
+
var _loop2 = function _loop2() {
|
|
3255
|
+
var trigger = _step2.value;
|
|
3256
|
+
if (!triggers.some(function (t) {
|
|
3257
|
+
return t.Name === trigger.Name;
|
|
3258
|
+
})) {
|
|
3259
|
+
logger('Extra trigger', trigger);
|
|
3260
|
+
differences.push({
|
|
3261
|
+
type: 'extra_trigger',
|
|
3262
|
+
tableName: _tableName,
|
|
3263
|
+
trigger: trigger
|
|
3264
|
+
});
|
|
3265
|
+
}
|
|
3266
|
+
};
|
|
3267
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
3268
|
+
_loop2();
|
|
3259
3269
|
}
|
|
3260
|
-
}
|
|
3261
|
-
|
|
3262
|
-
|
|
3270
|
+
} catch (err) {
|
|
3271
|
+
_iterator2.e(err);
|
|
3272
|
+
} finally {
|
|
3273
|
+
_iterator2.f();
|
|
3263
3274
|
}
|
|
3264
|
-
} catch (
|
|
3265
|
-
|
|
3266
|
-
} finally {
|
|
3267
|
-
_iterator2.f();
|
|
3275
|
+
} catch (e) {
|
|
3276
|
+
console.error("Error verifying triggers for table ".concat(_tableName), e);
|
|
3268
3277
|
}
|
|
3269
3278
|
var createTableSql = current.tables[_tableName].createSQL;
|
|
3270
3279
|
if (createTableSql === contents.createSQL) {
|
|
@@ -3275,14 +3284,6 @@ var findDifferences = function findDifferences(expected, current) {
|
|
|
3275
3284
|
logger(createTableSql);
|
|
3276
3285
|
logger(contents.createSQL);
|
|
3277
3286
|
}
|
|
3278
|
-
var columns = contents.columns,
|
|
3279
|
-
indexes = contents.indexes,
|
|
3280
|
-
triggers = contents.triggers;
|
|
3281
|
-
contents.createSQL;
|
|
3282
|
-
contents.name;
|
|
3283
|
-
contents.engine;
|
|
3284
|
-
contents.charset;
|
|
3285
|
-
contents.collate;
|
|
3286
3287
|
current.tables[_tableName].columns.map(function (f) {
|
|
3287
3288
|
return f.Field;
|
|
3288
3289
|
});
|
|
@@ -3566,7 +3567,7 @@ var findDifferences = function findDifferences(expected, current) {
|
|
|
3566
3567
|
return differences;
|
|
3567
3568
|
};
|
|
3568
3569
|
|
|
3569
|
-
var applyDifferences = /*#__PURE__*/function () {
|
|
3570
|
+
var applyDifferences$1 = /*#__PURE__*/function () {
|
|
3570
3571
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(connection, database, differences) {
|
|
3571
3572
|
var _iterator, _step, _loop, _ret;
|
|
3572
3573
|
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
@@ -4061,12 +4062,12 @@ var compareAllDatabases = /*#__PURE__*/function () {
|
|
|
4061
4062
|
expectedDatabases = expectedDatabases.filter(function (file) {
|
|
4062
4063
|
return file !== 'dumpInfo.json';
|
|
4063
4064
|
});
|
|
4064
|
-
|
|
4065
|
+
console.log('Expected databases from input directory:', expectedDatabases);
|
|
4065
4066
|
|
|
4066
4067
|
// Check existing databases
|
|
4067
|
-
_context.next =
|
|
4068
|
+
_context.next = 14;
|
|
4068
4069
|
return getDatabases(connection);
|
|
4069
|
-
case
|
|
4070
|
+
case 14:
|
|
4070
4071
|
existingDatabases = _context.sent;
|
|
4071
4072
|
// console.log('Existing databases:', existingDatabases);
|
|
4072
4073
|
allDifferences = {};
|
|
@@ -4075,20 +4076,20 @@ var compareAllDatabases = /*#__PURE__*/function () {
|
|
|
4075
4076
|
|
|
4076
4077
|
// Note missing databases and prepare to create them
|
|
4077
4078
|
_iterator = _createForOfIteratorHelper(expectedDatabases);
|
|
4078
|
-
_context.prev =
|
|
4079
|
+
_context.prev = 19;
|
|
4079
4080
|
_iterator.s();
|
|
4080
|
-
case
|
|
4081
|
+
case 21:
|
|
4081
4082
|
if ((_step = _iterator.n()).done) {
|
|
4082
|
-
_context.next =
|
|
4083
|
+
_context.next = 28;
|
|
4083
4084
|
break;
|
|
4084
4085
|
}
|
|
4085
4086
|
_database = _step.value;
|
|
4086
4087
|
if (!(options && options.database && options.database !== _database)) {
|
|
4087
|
-
_context.next =
|
|
4088
|
+
_context.next = 25;
|
|
4088
4089
|
break;
|
|
4089
4090
|
}
|
|
4090
|
-
return _context.abrupt("continue",
|
|
4091
|
-
case
|
|
4091
|
+
return _context.abrupt("continue", 26);
|
|
4092
|
+
case 25:
|
|
4092
4093
|
if (!existingDatabases.includes(_database)) {
|
|
4093
4094
|
allDifferences[_database] = [{
|
|
4094
4095
|
database: _database,
|
|
@@ -4097,58 +4098,58 @@ var compareAllDatabases = /*#__PURE__*/function () {
|
|
|
4097
4098
|
}];
|
|
4098
4099
|
missingDatabases.push(_database);
|
|
4099
4100
|
}
|
|
4100
|
-
case
|
|
4101
|
-
_context.next =
|
|
4101
|
+
case 26:
|
|
4102
|
+
_context.next = 21;
|
|
4102
4103
|
break;
|
|
4103
|
-
case
|
|
4104
|
-
_context.next =
|
|
4104
|
+
case 28:
|
|
4105
|
+
_context.next = 33;
|
|
4105
4106
|
break;
|
|
4106
|
-
case
|
|
4107
|
-
_context.prev =
|
|
4108
|
-
_context.t0 = _context["catch"](
|
|
4107
|
+
case 30:
|
|
4108
|
+
_context.prev = 30;
|
|
4109
|
+
_context.t0 = _context["catch"](19);
|
|
4109
4110
|
_iterator.e(_context.t0);
|
|
4110
|
-
case
|
|
4111
|
-
_context.prev =
|
|
4111
|
+
case 33:
|
|
4112
|
+
_context.prev = 33;
|
|
4112
4113
|
_iterator.f();
|
|
4113
|
-
return _context.finish(
|
|
4114
|
-
case
|
|
4114
|
+
return _context.finish(33);
|
|
4115
|
+
case 36:
|
|
4115
4116
|
if (!(missingDatabases.length > 0 && update)) {
|
|
4116
|
-
_context.next =
|
|
4117
|
+
_context.next = 59;
|
|
4117
4118
|
break;
|
|
4118
4119
|
}
|
|
4119
4120
|
console.log('Creating missing databases:');
|
|
4120
4121
|
_iterator2 = _createForOfIteratorHelper(missingDatabases);
|
|
4121
|
-
_context.prev =
|
|
4122
|
+
_context.prev = 39;
|
|
4122
4123
|
_iterator2.s();
|
|
4123
|
-
case
|
|
4124
|
+
case 41:
|
|
4124
4125
|
if ((_step2 = _iterator2.n()).done) {
|
|
4125
|
-
_context.next =
|
|
4126
|
+
_context.next = 49;
|
|
4126
4127
|
break;
|
|
4127
4128
|
}
|
|
4128
4129
|
database = _step2.value;
|
|
4129
4130
|
console.log("Creating database ".concat(database, "..."));
|
|
4130
|
-
_context.next =
|
|
4131
|
+
_context.next = 46;
|
|
4131
4132
|
return connection.query("CREATE DATABASE `".concat(database, "`;"));
|
|
4132
|
-
case 45:
|
|
4133
|
-
console.log("Database ".concat(database, " created."));
|
|
4134
4133
|
case 46:
|
|
4135
|
-
|
|
4134
|
+
console.log("Database ".concat(database, " created."));
|
|
4135
|
+
case 47:
|
|
4136
|
+
_context.next = 41;
|
|
4136
4137
|
break;
|
|
4137
|
-
case
|
|
4138
|
-
_context.next =
|
|
4138
|
+
case 49:
|
|
4139
|
+
_context.next = 54;
|
|
4139
4140
|
break;
|
|
4140
|
-
case
|
|
4141
|
-
_context.prev =
|
|
4142
|
-
_context.t1 = _context["catch"](
|
|
4141
|
+
case 51:
|
|
4142
|
+
_context.prev = 51;
|
|
4143
|
+
_context.t1 = _context["catch"](39);
|
|
4143
4144
|
_iterator2.e(_context.t1);
|
|
4144
|
-
case
|
|
4145
|
-
_context.prev =
|
|
4145
|
+
case 54:
|
|
4146
|
+
_context.prev = 54;
|
|
4146
4147
|
_iterator2.f();
|
|
4147
|
-
return _context.finish(
|
|
4148
|
-
case
|
|
4149
|
-
_context.next =
|
|
4148
|
+
return _context.finish(54);
|
|
4149
|
+
case 57:
|
|
4150
|
+
_context.next = 60;
|
|
4150
4151
|
break;
|
|
4151
|
-
case
|
|
4152
|
+
case 59:
|
|
4152
4153
|
if (missingDatabases.length > 0 && !update) {
|
|
4153
4154
|
console.error('Missing databases found but update is not enabled. Please enable update to create missing databases.');
|
|
4154
4155
|
console.error('Please run the command again with the --update flag to create missing databases.');
|
|
@@ -4157,87 +4158,87 @@ var compareAllDatabases = /*#__PURE__*/function () {
|
|
|
4157
4158
|
} else {
|
|
4158
4159
|
console.log('All expected databases exist.');
|
|
4159
4160
|
}
|
|
4160
|
-
case
|
|
4161
|
+
case 60:
|
|
4161
4162
|
_iterator3 = _createForOfIteratorHelper(expectedDatabases);
|
|
4162
|
-
_context.prev =
|
|
4163
|
+
_context.prev = 61;
|
|
4163
4164
|
_iterator3.s();
|
|
4164
|
-
case
|
|
4165
|
+
case 63:
|
|
4165
4166
|
if ((_step3 = _iterator3.n()).done) {
|
|
4166
|
-
_context.next =
|
|
4167
|
+
_context.next = 101;
|
|
4167
4168
|
break;
|
|
4168
4169
|
}
|
|
4169
4170
|
_database2 = _step3.value;
|
|
4170
4171
|
if (!(options && options.database && options.database !== _database2)) {
|
|
4171
|
-
_context.next =
|
|
4172
|
+
_context.next = 67;
|
|
4172
4173
|
break;
|
|
4173
4174
|
}
|
|
4174
|
-
return _context.abrupt("continue",
|
|
4175
|
-
case
|
|
4175
|
+
return _context.abrupt("continue", 99);
|
|
4176
|
+
case 67:
|
|
4176
4177
|
if (!missingDatabases.includes(_database2)) {
|
|
4177
|
-
_context.next =
|
|
4178
|
+
_context.next = 70;
|
|
4178
4179
|
break;
|
|
4179
4180
|
}
|
|
4180
4181
|
console.log('Skipping database', _database2, 'because it is missing');
|
|
4181
|
-
return _context.abrupt("continue",
|
|
4182
|
-
case
|
|
4182
|
+
return _context.abrupt("continue", 99);
|
|
4183
|
+
case 70:
|
|
4183
4184
|
filePath = path.join(inputDir, _database2, "".concat(_database2, ".json"));
|
|
4184
|
-
_context.prev =
|
|
4185
|
-
_context.next =
|
|
4185
|
+
_context.prev = 71;
|
|
4186
|
+
_context.next = 74;
|
|
4186
4187
|
return fs$1.readFile(filePath, 'utf-8');
|
|
4187
|
-
case
|
|
4188
|
+
case 74:
|
|
4188
4189
|
fileContent = _context.sent;
|
|
4189
4190
|
expectedStructure = JSON.parse(fileContent);
|
|
4190
4191
|
console.log('Getting database structure for', _database2);
|
|
4191
|
-
_context.next =
|
|
4192
|
+
_context.next = 79;
|
|
4192
4193
|
return getDatabaseStructure(connection, _database2, command, options);
|
|
4193
|
-
case
|
|
4194
|
+
case 79:
|
|
4194
4195
|
currentStructure = _context.sent;
|
|
4195
4196
|
console.log('Database structure for', _database2, 'obtained');
|
|
4196
4197
|
differences = findDifferences(expectedStructure, currentStructure);
|
|
4197
4198
|
console.log('Differences for', _database2, 'obtained');
|
|
4198
4199
|
if (update) {
|
|
4199
|
-
_context.next =
|
|
4200
|
+
_context.next = 88;
|
|
4200
4201
|
break;
|
|
4201
4202
|
}
|
|
4202
4203
|
console.log('Logging differences for', _database2);
|
|
4203
4204
|
logDifferences(differences, _database2, true);
|
|
4204
|
-
_context.next =
|
|
4205
|
+
_context.next = 93;
|
|
4205
4206
|
break;
|
|
4206
|
-
case
|
|
4207
|
+
case 88:
|
|
4207
4208
|
console.log('Logging differences for', _database2);
|
|
4208
4209
|
logDifferences(differences, _database2, false);
|
|
4209
4210
|
console.log('Applying differences for', _database2);
|
|
4210
|
-
_context.next =
|
|
4211
|
-
return applyDifferences(connection, _database2, differences);
|
|
4212
|
-
case
|
|
4211
|
+
_context.next = 93;
|
|
4212
|
+
return applyDifferences$1(connection, _database2, differences);
|
|
4213
|
+
case 93:
|
|
4213
4214
|
allDifferences[_database2] = differences;
|
|
4214
|
-
_context.next =
|
|
4215
|
+
_context.next = 99;
|
|
4215
4216
|
break;
|
|
4216
|
-
case
|
|
4217
|
-
_context.prev =
|
|
4218
|
-
_context.t2 = _context["catch"](
|
|
4217
|
+
case 96:
|
|
4218
|
+
_context.prev = 96;
|
|
4219
|
+
_context.t2 = _context["catch"](71);
|
|
4219
4220
|
console.error("Error processing database ".concat(_database2, ":"), _context.t2.message);
|
|
4220
|
-
case
|
|
4221
|
-
_context.next =
|
|
4221
|
+
case 99:
|
|
4222
|
+
_context.next = 63;
|
|
4222
4223
|
break;
|
|
4223
|
-
case
|
|
4224
|
-
_context.next =
|
|
4224
|
+
case 101:
|
|
4225
|
+
_context.next = 106;
|
|
4225
4226
|
break;
|
|
4226
|
-
case
|
|
4227
|
-
_context.prev =
|
|
4228
|
-
_context.t3 = _context["catch"](
|
|
4227
|
+
case 103:
|
|
4228
|
+
_context.prev = 103;
|
|
4229
|
+
_context.t3 = _context["catch"](61);
|
|
4229
4230
|
_iterator3.e(_context.t3);
|
|
4230
|
-
case
|
|
4231
|
-
_context.prev =
|
|
4231
|
+
case 106:
|
|
4232
|
+
_context.prev = 106;
|
|
4232
4233
|
_iterator3.f();
|
|
4233
|
-
return _context.finish(
|
|
4234
|
-
case 108:
|
|
4235
|
-
return _context.abrupt("return", allDifferences);
|
|
4234
|
+
return _context.finish(106);
|
|
4236
4235
|
case 109:
|
|
4236
|
+
return _context.abrupt("return", allDifferences);
|
|
4237
|
+
case 110:
|
|
4237
4238
|
case "end":
|
|
4238
4239
|
return _context.stop();
|
|
4239
4240
|
}
|
|
4240
|
-
}, _callee, null, [[
|
|
4241
|
+
}, _callee, null, [[19, 30, 33, 36], [39, 51, 54, 57], [61, 103, 106, 109], [71, 96]]);
|
|
4241
4242
|
}));
|
|
4242
4243
|
return function compareAllDatabases(_x, _x2) {
|
|
4243
4244
|
return _ref.apply(this, arguments);
|
|
@@ -4479,7 +4480,7 @@ var startApiServer = function startApiServer(port, argv) {
|
|
|
4479
4480
|
_context6.prev = 4;
|
|
4480
4481
|
console.log('Applying the database structure based on JSON dumps');
|
|
4481
4482
|
_context6.next = 8;
|
|
4482
|
-
return applyDifferences(checker.connection, database, diffs);
|
|
4483
|
+
return applyDifferences$1(checker.connection, database, diffs);
|
|
4483
4484
|
case 8:
|
|
4484
4485
|
res.json({
|
|
4485
4486
|
message: 'Apply completed successfully'
|
|
@@ -5207,43 +5208,146 @@ var DBStructureChecker = /*#__PURE__*/function () {
|
|
|
5207
5208
|
}]);
|
|
5208
5209
|
}();
|
|
5209
5210
|
var compare = /*#__PURE__*/function () {
|
|
5210
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5211
|
-
return _regeneratorRuntime().wrap(function
|
|
5212
|
-
while (1) switch (
|
|
5211
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(config, output) {
|
|
5212
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
5213
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
5214
|
+
case 0:
|
|
5215
|
+
return _context5.abrupt("return", new Promise(/*#__PURE__*/function () {
|
|
5216
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(resolve, reject) {
|
|
5217
|
+
var _checker;
|
|
5218
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
5219
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
5220
|
+
case 0:
|
|
5221
|
+
_context4.prev = 0;
|
|
5222
|
+
_checker = new DBStructureChecker(config);
|
|
5223
|
+
_checker.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
5224
|
+
var diffs;
|
|
5225
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
5226
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
5227
|
+
case 0:
|
|
5228
|
+
_context3.next = 2;
|
|
5229
|
+
return compareAllDatabases(_checker.connection, output, false, 'compare', {
|
|
5230
|
+
output: output
|
|
5231
|
+
});
|
|
5232
|
+
case 2:
|
|
5233
|
+
diffs = _context3.sent;
|
|
5234
|
+
resolve({
|
|
5235
|
+
type: 'success',
|
|
5236
|
+
diffs: diffs
|
|
5237
|
+
});
|
|
5238
|
+
case 4:
|
|
5239
|
+
case "end":
|
|
5240
|
+
return _context3.stop();
|
|
5241
|
+
}
|
|
5242
|
+
}, _callee3);
|
|
5243
|
+
})));
|
|
5244
|
+
_context4.next = 8;
|
|
5245
|
+
break;
|
|
5246
|
+
case 5:
|
|
5247
|
+
_context4.prev = 5;
|
|
5248
|
+
_context4.t0 = _context4["catch"](0);
|
|
5249
|
+
reject({
|
|
5250
|
+
type: 'error',
|
|
5251
|
+
error: _context4.t0.message
|
|
5252
|
+
});
|
|
5253
|
+
case 8:
|
|
5254
|
+
_context4.prev = 8;
|
|
5255
|
+
_context4.next = 11;
|
|
5256
|
+
return checker.closeConnection();
|
|
5257
|
+
case 11:
|
|
5258
|
+
return _context4.finish(8);
|
|
5259
|
+
case 12:
|
|
5260
|
+
case "end":
|
|
5261
|
+
return _context4.stop();
|
|
5262
|
+
}
|
|
5263
|
+
}, _callee4, null, [[0, 5, 8, 12]]);
|
|
5264
|
+
}));
|
|
5265
|
+
return function (_x3, _x4) {
|
|
5266
|
+
return _ref2.apply(this, arguments);
|
|
5267
|
+
};
|
|
5268
|
+
}()));
|
|
5269
|
+
case 1:
|
|
5270
|
+
case "end":
|
|
5271
|
+
return _context5.stop();
|
|
5272
|
+
}
|
|
5273
|
+
}, _callee5);
|
|
5274
|
+
}));
|
|
5275
|
+
return function compare(_x, _x2) {
|
|
5276
|
+
return _ref.apply(this, arguments);
|
|
5277
|
+
};
|
|
5278
|
+
}();
|
|
5279
|
+
var apply = /*#__PURE__*/function () {
|
|
5280
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(config, database, diffs) {
|
|
5281
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
5282
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
5213
5283
|
case 0:
|
|
5214
|
-
return
|
|
5284
|
+
return _context7.abrupt("return", new Promise(function (resolve, reject) {
|
|
5215
5285
|
try {
|
|
5216
|
-
var
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5286
|
+
var _checker2 = new DBStructureChecker(config, database);
|
|
5287
|
+
_checker2.connection.on('error', function (err) {
|
|
5288
|
+
console.error('Database connection error in route apply:', err);
|
|
5289
|
+
reject({
|
|
5290
|
+
type: 'error',
|
|
5291
|
+
error: err.message
|
|
5292
|
+
});
|
|
5293
|
+
});
|
|
5294
|
+
_checker2.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
5295
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
5296
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
5221
5297
|
case 0:
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5298
|
+
console.log('Connected to the database');
|
|
5299
|
+
_checker2.targetDatabase = database;
|
|
5300
|
+
_checker2.command = 'apply';
|
|
5301
|
+
_checker2.options = {
|
|
5302
|
+
config: config,
|
|
5303
|
+
database: database,
|
|
5304
|
+
diffs: diffs
|
|
5305
|
+
};
|
|
5306
|
+
_context6.prev = 4;
|
|
5307
|
+
console.log('Applying the database structure based on JSON dumps');
|
|
5308
|
+
_context6.next = 8;
|
|
5309
|
+
return applyDifferences(_checker2.connection, database, diffs);
|
|
5310
|
+
case 8:
|
|
5311
|
+
resolve({
|
|
5312
|
+
type: 'success',
|
|
5313
|
+
message: 'Apply completed successfully'
|
|
5225
5314
|
});
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5315
|
+
_context6.next = 14;
|
|
5316
|
+
break;
|
|
5317
|
+
case 11:
|
|
5318
|
+
_context6.prev = 11;
|
|
5319
|
+
_context6.t0 = _context6["catch"](4);
|
|
5320
|
+
reject({
|
|
5321
|
+
type: 'error',
|
|
5322
|
+
error: _context6.t0.message
|
|
5323
|
+
});
|
|
5324
|
+
case 14:
|
|
5325
|
+
_context6.prev = 14;
|
|
5326
|
+
_context6.next = 17;
|
|
5327
|
+
return _checker2.closeConnection();
|
|
5328
|
+
case 17:
|
|
5329
|
+
return _context6.finish(14);
|
|
5330
|
+
case 18:
|
|
5230
5331
|
case "end":
|
|
5231
|
-
return
|
|
5332
|
+
return _context6.stop();
|
|
5232
5333
|
}
|
|
5233
|
-
},
|
|
5334
|
+
}, _callee6, null, [[4, 11, 14, 18]]);
|
|
5234
5335
|
})));
|
|
5235
5336
|
} catch (e) {
|
|
5236
|
-
reject(
|
|
5337
|
+
reject({
|
|
5338
|
+
type: 'error',
|
|
5339
|
+
error: e.message
|
|
5340
|
+
});
|
|
5237
5341
|
}
|
|
5238
5342
|
}));
|
|
5239
5343
|
case 1:
|
|
5240
5344
|
case "end":
|
|
5241
|
-
return
|
|
5345
|
+
return _context7.stop();
|
|
5242
5346
|
}
|
|
5243
|
-
},
|
|
5347
|
+
}, _callee7);
|
|
5244
5348
|
}));
|
|
5245
|
-
return function
|
|
5246
|
-
return
|
|
5349
|
+
return function apply(_x5, _x6, _x7) {
|
|
5350
|
+
return _ref4.apply(this, arguments);
|
|
5247
5351
|
};
|
|
5248
5352
|
}();
|
|
5249
5353
|
|
|
@@ -5259,15 +5363,15 @@ var isMain = function () {
|
|
|
5259
5363
|
}
|
|
5260
5364
|
}();
|
|
5261
5365
|
if (isMain) {
|
|
5262
|
-
_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5263
|
-
var _cli, command, config, argv, PORT,
|
|
5264
|
-
return _regeneratorRuntime().wrap(function
|
|
5265
|
-
while (1) switch (
|
|
5366
|
+
_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
5367
|
+
var _cli, command, config, argv, PORT, _checker3;
|
|
5368
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
5369
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
5266
5370
|
case 0:
|
|
5267
5371
|
_cli = cli(), command = _cli.command, config = _cli.config, argv = _cli.argv;
|
|
5268
5372
|
console.log("MySQLsyncr started via command line");
|
|
5269
5373
|
if (!(command === 'ui')) {
|
|
5270
|
-
|
|
5374
|
+
_context9.next = 12;
|
|
5271
5375
|
break;
|
|
5272
5376
|
}
|
|
5273
5377
|
PORT = argv.uiPort;
|
|
@@ -5275,58 +5379,58 @@ if (isMain) {
|
|
|
5275
5379
|
console.log('Server started on port', PORT);
|
|
5276
5380
|
console.log('Open http://localhost:' + PORT + ' in your browser to use the UI');
|
|
5277
5381
|
if (!(argv.openUI && argv.openUI === true || argv.openUI === 'true')) {
|
|
5278
|
-
|
|
5382
|
+
_context9.next = 10;
|
|
5279
5383
|
break;
|
|
5280
5384
|
}
|
|
5281
|
-
|
|
5385
|
+
_context9.next = 10;
|
|
5282
5386
|
return open("http://localhost:".concat(PORT));
|
|
5283
5387
|
case 10:
|
|
5284
|
-
|
|
5388
|
+
_context9.next = 14;
|
|
5285
5389
|
break;
|
|
5286
5390
|
case 12:
|
|
5287
5391
|
// Handle other commands (dump, compare, update) as before
|
|
5288
|
-
|
|
5289
|
-
|
|
5392
|
+
_checker3 = new DBStructureChecker(config, argv.database);
|
|
5393
|
+
_checker3.connection.on('connect', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
5290
5394
|
var diffs, totalDiffs, _totalDiffs, previousDiffs, runCount, maxRuns, _diffs;
|
|
5291
|
-
return _regeneratorRuntime().wrap(function
|
|
5292
|
-
while (1) switch (
|
|
5395
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
5396
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
5293
5397
|
case 0:
|
|
5294
5398
|
console.log('Connected to the database');
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5399
|
+
_checker3.targetDatabase = argv.database;
|
|
5400
|
+
_checker3.command = command;
|
|
5401
|
+
_checker3.options = argv;
|
|
5402
|
+
_context8.prev = 4;
|
|
5299
5403
|
if (!(command === 'dump')) {
|
|
5300
|
-
|
|
5404
|
+
_context8.next = 11;
|
|
5301
5405
|
break;
|
|
5302
5406
|
}
|
|
5303
5407
|
console.log('Dumping the database structure to files');
|
|
5304
|
-
|
|
5305
|
-
return dumpAllDatabases(
|
|
5408
|
+
_context8.next = 9;
|
|
5409
|
+
return dumpAllDatabases(_checker3.connection, command, argv);
|
|
5306
5410
|
case 9:
|
|
5307
|
-
|
|
5411
|
+
_context8.next = 42;
|
|
5308
5412
|
break;
|
|
5309
5413
|
case 11:
|
|
5310
5414
|
if (!(command === 'compare')) {
|
|
5311
|
-
|
|
5415
|
+
_context8.next = 21;
|
|
5312
5416
|
break;
|
|
5313
5417
|
}
|
|
5314
5418
|
console.log('Comparing the database structure with JSON dumps (dry run)');
|
|
5315
|
-
|
|
5316
|
-
return compareAllDatabases(
|
|
5419
|
+
_context8.next = 15;
|
|
5420
|
+
return compareAllDatabases(_checker3.connection, argv.output, false, command, argv);
|
|
5317
5421
|
case 15:
|
|
5318
|
-
diffs =
|
|
5422
|
+
diffs = _context8.sent;
|
|
5319
5423
|
// Dry run
|
|
5320
5424
|
totalDiffs = Object.values(diffs).reduce(function (acc, arr) {
|
|
5321
5425
|
return acc + arr.length;
|
|
5322
5426
|
}, 0);
|
|
5323
5427
|
console.log('Total differences count:', totalDiffs);
|
|
5324
5428
|
fs.writeFileSync(path.join(argv.output, 'diffs.json'), JSON.stringify(diffs, null, 4));
|
|
5325
|
-
|
|
5429
|
+
_context8.next = 42;
|
|
5326
5430
|
break;
|
|
5327
5431
|
case 21:
|
|
5328
5432
|
if (!(command === 'update')) {
|
|
5329
|
-
|
|
5433
|
+
_context8.next = 42;
|
|
5330
5434
|
break;
|
|
5331
5435
|
}
|
|
5332
5436
|
console.log('Updating the database structure based on JSON dumps');
|
|
@@ -5336,14 +5440,14 @@ if (isMain) {
|
|
|
5336
5440
|
maxRuns = 6;
|
|
5337
5441
|
case 27:
|
|
5338
5442
|
if (!(runCount < maxRuns && _totalDiffs > 0 && (_totalDiffs < previousDiffs || previousDiffs === Infinity))) {
|
|
5339
|
-
|
|
5443
|
+
_context8.next = 42;
|
|
5340
5444
|
break;
|
|
5341
5445
|
}
|
|
5342
5446
|
console.log('Running update command. Run count:', runCount);
|
|
5343
|
-
|
|
5344
|
-
return compareAllDatabases(
|
|
5447
|
+
_context8.next = 31;
|
|
5448
|
+
return compareAllDatabases(_checker3.connection, argv.output, true, command, argv);
|
|
5345
5449
|
case 31:
|
|
5346
|
-
_diffs =
|
|
5450
|
+
_diffs = _context8.sent;
|
|
5347
5451
|
// Apply updates
|
|
5348
5452
|
previousDiffs = _totalDiffs; // Update previous differences
|
|
5349
5453
|
_totalDiffs = Object.values(_diffs).reduce(function (acc, arr) {
|
|
@@ -5352,45 +5456,46 @@ if (isMain) {
|
|
|
5352
5456
|
console.log('Total differences count:', _totalDiffs);
|
|
5353
5457
|
runCount++;
|
|
5354
5458
|
if (!(_totalDiffs > 0 && runCount < maxRuns)) {
|
|
5355
|
-
|
|
5459
|
+
_context8.next = 40;
|
|
5356
5460
|
break;
|
|
5357
5461
|
}
|
|
5358
5462
|
console.log('Total differences count is still greater than 0. Waiting 1 second before next run. Run count:', runCount);
|
|
5359
|
-
|
|
5463
|
+
_context8.next = 40;
|
|
5360
5464
|
return new Promise(function (resolve) {
|
|
5361
5465
|
return setTimeout(resolve, 1000);
|
|
5362
5466
|
});
|
|
5363
5467
|
case 40:
|
|
5364
|
-
|
|
5468
|
+
_context8.next = 27;
|
|
5365
5469
|
break;
|
|
5366
5470
|
case 42:
|
|
5367
|
-
|
|
5471
|
+
_context8.next = 47;
|
|
5368
5472
|
break;
|
|
5369
5473
|
case 44:
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
console.error(
|
|
5474
|
+
_context8.prev = 44;
|
|
5475
|
+
_context8.t0 = _context8["catch"](4);
|
|
5476
|
+
console.error(_context8.t0.message);
|
|
5373
5477
|
case 47:
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
return
|
|
5478
|
+
_context8.prev = 47;
|
|
5479
|
+
_context8.next = 50;
|
|
5480
|
+
return _checker3.closeConnection();
|
|
5377
5481
|
case 50:
|
|
5378
|
-
return
|
|
5482
|
+
return _context8.finish(47);
|
|
5379
5483
|
case 51:
|
|
5380
5484
|
case "end":
|
|
5381
|
-
return
|
|
5485
|
+
return _context8.stop();
|
|
5382
5486
|
}
|
|
5383
|
-
},
|
|
5487
|
+
}, _callee8, null, [[4, 44, 47, 51]]);
|
|
5384
5488
|
})));
|
|
5385
5489
|
case 14:
|
|
5386
5490
|
case "end":
|
|
5387
|
-
return
|
|
5491
|
+
return _context9.stop();
|
|
5388
5492
|
}
|
|
5389
|
-
},
|
|
5493
|
+
}, _callee9);
|
|
5390
5494
|
}))();
|
|
5391
5495
|
}
|
|
5392
5496
|
|
|
5393
5497
|
exports.DBStructureChecker = DBStructureChecker;
|
|
5498
|
+
exports.apply = apply;
|
|
5394
5499
|
exports.compare = compare;
|
|
5395
5500
|
exports.dumpAllDatabases = dumpAllDatabases;
|
|
5396
5501
|
exports.startApiServer = startApiServer;
|