Verify the migrated data

Compare the counts and indexes of each collection between MongoDB and TeselaDB, plus the sum of one field, before moving the traffic.

Compare the data in MongoDB and in TeselaDB before moving the traffic. Run the same queries on both and compare the results.

Requirements

  • Read access to both databases.

Counts and indexes

JavaScript
db.orders.countDocuments();
db.orders.getIndexes();

Sums per collection

A sum of a numeric field detects documents that are missing or changed:

JavaScript
db.orders.aggregate([{ $group: { _id: null, n: { $sum: 1 }, total: { $sum: "$total" } } }]);

Check

The three checks give the same result in MongoDB and in TeselaDB for each collection.

Common problems

  • The counts do not match because the application kept writing to MongoDB during the copy. Copy with --oplog or stop the writes.

See also