The columns are not the fields you want

DBToMongo » Use cases » Reshape the fields

Download DBToMongo Free Trial »     Buy DBToMongo Now »

The situation

A mechanical copy gives you the old schema wearing a new hat: CUST_NBR instead of customerNumber, a date stored as a string, a column that was only ever used by the old application, a numeric code that the new service expects as text. The documents load, and then every query has to work around the names and types.

Fixing it after the migration means an update pass over the whole collection - a second copy of the problem.

What you do

  1. Open the mapping for the table you are migrating (Table to Collection).
  2. For each source column, set the destination field: rename it, and change its type if the target wants something else.
  3. Untick the columns that should not travel at all - legacy flags, internal IDs, duplicated columns.
  4. Preview, then run. The documents are written in the shape you mapped, on the first pass.

Mapping source columns to MongoDB fields in DBToMongo

Because the mapping belongs to the task, a migration that has to be repeated - the next release, the next tenant, the test environment - produces the same shaped documents every time instead of depending on someone remembering the rules.

What it will not do

Related

The mode: table to collection, and the same mapping across many tables: similar tables to one collection. The whole database: migrate a database. From a query with the columns already reduced: query to collection.