I have a AWS DocumentDB with schema my-schema and table called my-table which has a structure something like
{
"_id": { "FIELD_1" : "001", "FIELD_2" : "A1" },
"FIELD_1": "001",
"FILED_2": "A1",
.
.
.
}
as you can see that the _id contains FIELD_1 & FIELD_2. combination of these two fields are unique for all the records. These two fields formed the composite primary key in the original oracle db that is why when we migrated from oracle to DocumentDB, AWS DMS chose to put that into _id.
Now the problem is, we need _id to be a mongodb ObjectId instead of a nested json.
What I have tried is:
- create a source endpoint with my DocumentDB (which contains this bad _id data, in schema
my-schema). - create a target endpoint with the same DocumentDB but with new schema
my-new-schemaand same table namemy-table. - Then I migrate the data from my-schema to my-new-schema using transformations (remove column _id).
But It still replicates the same nested _id into the target table.
I have tried both document metadata mode & table metadata mode.
In table metadata mode, it doesn't even transfer data because after it flattens the _id into _id.FIELD_1 & _id.FIELD_2. DMS throws an exception "Document can't have '.' in field names"
I know that I can do this easily using code but if it is somehow possible to achieve my goal using DMS I would prefer that.
or can we achieve this using mongodb commands directly?