- Newest
- Most votes
- Most comments
When migrating from DocumentDB to PostgreSQL using AWS DMS, you have two migration modes to choose from that affect how your data is mapped:
Table Mode (Recommended for your scenario): In table mode, AWS DMS transforms each top-level field in your DocumentDB document into a column in the target PostgreSQL table. This mode automatically handles the mapping of fields like _id, client_id, rep_id, etc., to corresponding columns in your target table.
For your created_date field appearing as null, this could be due to a few factors:
-
Data Type Mismatch: Your source has created_date as a string ("2026-02-06"), but your target expects a date format. You may need to use transformation rules to convert the string to a proper date format.
-
Column Mapping: To handle different structures and ordering between source and target, you can use transformation rules with expressions. You can add transformation rules to:
- Map specific source columns to target columns
- Convert data types (like string to date)
- Handle format conversions
- Scanning Documents: AWS DMS scans a specified number of documents (default 1000) to determine the field structure and data types. If your created_date field isn't consistently present in the scanned documents, it might not be properly mapped.
Recommendations:
- Use table mode for better column-level control
- Implement transformation rules to handle the date format conversion from string to date type
- Ensure your transformation rules explicitly map each source field to the corresponding target column
- Consider using expressions in transformation rules to convert the string date format to the proper date data type expected by PostgreSQL
You can configure these settings when creating your DocumentDB source endpoint using either the Metadata mode option in the console or through extra connection attributes.
Sources
Using Amazon DocumentDB (with MongoDB compatibility) as a source for AWS DMS - AWS Database Migration Service
Using MongoDB as a source for AWS DMS - AWS Database Migration Service
Using transformation rule expressions to define column content - AWS Database Migration Service
In AWS DMS, DocumentDB→Postgres won’t always auto-convert string dates to a DATE column. If created_date is stored as a string ("2026-02-06"), DMS can land it as NULL unless you transform it.
Fix
- Store ISODate in source (best):
db.col.updateMany( { created_date: { $type: "string" } }, [{ $set: { created_date: { $dateFromString: { dateString: "$created_date" } } } }] )
- DMS transformation rule (map + type/format): use task “Transformation rules” to map
created_dateto target and apply a conversion (string→date). Validate in task logs.
Quick checks
-- Postgres target SELECT created_date FROM target_table WHERE client_id='44354302';
aws dms describe-table-statistics --replication-task-arn <arn>
answered 9 months ago
Relevant content
asked 9 months ago
