mysqlsyncr 1.0.3 → 1.0.4
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/package.json +1 -1
- package/src/compare.js +8 -1
- package/src/index.js +2 -2
package/package.json
CHANGED
package/src/compare.js
CHANGED
|
@@ -10,7 +10,9 @@ export const compareAllDatabases = async (connection, inputDir, update = false,
|
|
|
10
10
|
await connection.reconnect(); // Ensure the connection is open
|
|
11
11
|
}
|
|
12
12
|
// Read the expected databases from the input directory
|
|
13
|
-
|
|
13
|
+
let expectedDatabases = await fs.readdir(inputDir);
|
|
14
|
+
//filter out diffs.json
|
|
15
|
+
expectedDatabases = expectedDatabases.filter(file => file !== 'diffs.json');
|
|
14
16
|
// console.log('Expected databases from input directory:', expectedDatabases);
|
|
15
17
|
|
|
16
18
|
// Check existing databases
|
|
@@ -57,7 +59,12 @@ export const compareAllDatabases = async (connection, inputDir, update = false,
|
|
|
57
59
|
if(options.database && options.database !== database){
|
|
58
60
|
continue;
|
|
59
61
|
}
|
|
62
|
+
if(missingDatabases.includes(database)){
|
|
63
|
+
console.log('Skipping database', database, 'because it is missing');
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
60
66
|
const filePath = path.join(inputDir, database, `${database}.json`);
|
|
67
|
+
|
|
61
68
|
try {
|
|
62
69
|
const fileContent = await fs.readFile(filePath, 'utf-8');
|
|
63
70
|
const expectedStructure = JSON.parse(fileContent);
|
package/src/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import mysql from 'mysql2';
|
|
4
4
|
import util from 'util';
|
|
5
5
|
import fs from 'fs';
|
|
6
|
-
|
|
6
|
+
import path from 'path';
|
|
7
7
|
import { cli } from './cli.js';
|
|
8
8
|
import { dumpAllDatabases } from './dump.js';
|
|
9
9
|
import { compareAllDatabases } from './compare.js';
|
|
@@ -54,7 +54,7 @@ class DBStructureChecker {
|
|
|
54
54
|
let diffs = await compareAllDatabases(checker.connection, argv.output, false, command, argv); // Dry run
|
|
55
55
|
let totalDiffs = Object.values(diffs).reduce((acc, arr) => acc + arr.length, 0);
|
|
56
56
|
console.log('Total differences count:', totalDiffs);
|
|
57
|
-
fs.writeFileSync(argv.output
|
|
57
|
+
fs.writeFileSync(path.join(argv.output, 'diffs.json'), JSON.stringify(diffs, null, 4));
|
|
58
58
|
} else if (command === 'update') {
|
|
59
59
|
console.log('Updating the database structure based on JSON dumps');
|
|
60
60
|
let totalDiffs = Infinity; // Initialize with a large number
|