SQL Migration & Task Manager
SQL Migration isn't a standalone activity — it's a class of job you configure inside the Task Manager. A migration is just a task whose source and target combine a SQL connection with a MongoDB connection (in either direction). See the Task Manager doc for creating, scheduling, and monitoring jobs; this page is the reference for what SQL migration jobs can do.
Migrate data between MongoDB and relational databases with intelligent type mapping, schema generation, and full CDC-backed replication. VisuaLeaf supports one-shot snapshots, ongoing streaming replication, and bidirectional-optional sync between MongoDB and PostgreSQL, MySQL, MariaDB, SQL Server, and Oracle. Under the hood it embeds Debezium 2.5.4 to read the source database's binlog or logical-replication stream — the same battle-tested engine used by Confluent, Airbyte, and Materialize.
Rather than polling the source database with repeated SELECT *, VisuaLeaf captures changes directly from the transaction log. This means:
| Database | Log Source | Required Setup |
|---|---|---|
| PostgreSQL 10+ | Logical replication (pgoutput) |
wal_level = logical, replication role, publication |
| MySQL 5.7+ / 8.0+ | Row-based binlog | binlog_format = ROW, binlog_row_image = FULL |
| MariaDB 10.4+ | Row-based binlog (MySQL-compatible) | Same as MySQL |
| SQL Server 2016+ | CDC (Change Data Capture) | sys.sp_cdc_enable_db and sys.sp_cdc_enable_table |
| Oracle 12c+ | LogMiner or XStream | Supplemental logging on tracked tables |
Add these in Connection Manager. VisuaLeaf validates the CDC prerequisites and warns you if configuration is missing.
# PostgreSQL
jdbc:postgresql://db.internal:5432/appdb?user=debezium&password=***&sslmode=require
# MySQL
jdbc:mysql://db.internal:3306/appdb?user=debezium&password=***&useSSL=true
# SQL Server
jdbc:sqlserver://sqlserver.internal:1433;databaseName=appdb;user=debezium;password=***;encrypt=true
# Oracle
jdbc:oracle:thin:debezium/***@//ora.internal:1521/ORCLPDB1
Set up a SQL migration in minutes:
Import data from SQL databases into MongoDB using these source options.
| Source Type | Description | Use Case |
|---|---|---|
SQL Table |
Import all rows from a SQL table | Full table migration to MongoDB collection |
SQL View |
Import from a SQL view (pre-joined/filtered data) | Import denormalized data from multiple tables |
SQL Query |
Import using custom SELECT statement | Complex joins, filters, or transformations at source |
Export MongoDB data to SQL databases using these target options.
| Target Type | Description | Use Case |
|---|---|---|
SQL Table |
Export directly to a SQL database table | Live migration with Insert/Upsert/DropInsert modes |
SQL Script |
Generate SQL INSERT/UPDATE statements as a file | Review before execution, version control, manual apply |
VisuaLeaf supports migration to and from major relational databases.
| Database | Versions | Features |
|---|---|---|
| MySQL | 5.7+, 8.0+ | JSON columns, SSL/TLS, connection pooling |
| PostgreSQL | 10+, 12+, 14+, 16+ | JSONB columns, array types, SSL/TLS |
| SQL Server | 2016+, 2019+, 2022+ | Windows/Linux, Azure SQL, SSL/TLS |
| Oracle | 12c+, 19c+, 21c+ | JSON columns, connection pooling |
VisuaLeaf automatically maps between SQL and MongoDB types, with per-field manual override in the mapping UI. Type coercion is deterministic and driven by the source column metadata Debezium extracts from the transaction log.
| SQL Type | MongoDB / BSON Type | Notes |
|---|---|---|
SMALLINT, INT, INTEGER |
Int32 | 32-bit signed integer |
BIGINT |
Int64 (Long) | 64-bit signed integer — preserved as NumberLong |
DECIMAL, NUMERIC |
Decimal128 | Lossless decimal preservation, ideal for financial data |
REAL, FLOAT, DOUBLE |
Double | IEEE 754 double precision |
BOOLEAN, BIT(1), TINYINT(1) |
Boolean | MySQL TINYINT(1) auto-detected as boolean |
CHAR, VARCHAR, TEXT, NVARCHAR |
String (UTF-8) | All character types normalized to UTF-8 |
DATE |
Date (midnight UTC) | Time component zeroed |
TIME, TIMETZ |
String (ISO 8601 time) | Preserved as-is |
TIMESTAMP, TIMESTAMPTZ, DATETIME |
Date (BSON UTC datetime) | Millisecond precision; timezone normalized to UTC |
JSON, JSONB |
BSON Document (nested) | Parsed and embedded as a nested subdocument — not a string |
ARRAY[] (PostgreSQL) |
Array | Elements typed per column definition |
UUID |
Binary (subtype 4) or String | Configurable; default is Binary UUID |
BLOB, BYTEA, VARBINARY, IMAGE |
Binary (subtype 0) | Raw bytes preserved — large blobs can be routed to GridFS |
ENUM |
String | Enum label; original definition kept in a metadata sidecar collection |
NULL |
null | Preserved |
| MongoDB Type | MySQL | PostgreSQL | SQL Server |
|---|---|---|---|
| String | VARCHAR / TEXT | VARCHAR / TEXT | NVARCHAR / NTEXT |
| Number (Int) | INT / BIGINT | INTEGER / BIGINT | INT / BIGINT |
| Number (Double) | DOUBLE | DOUBLE PRECISION | FLOAT |
| Boolean | TINYINT(1) | BOOLEAN | BIT |
| Date | DATETIME | TIMESTAMP | DATETIME2 |
| ObjectId | CHAR(24) | CHAR(24) | CHAR(24) |
| Object / Array | JSON | JSONB | NVARCHAR(MAX) |
Configure SQL column properties for each mapped field.
Control how data is written to the target (whether that's a SQL table or a Mongo collection). Write modes apply symmetrically in both directions.
| Mode | Behavior | Use Case |
|---|---|---|
| Append (Insert) | Insert new rows only, fail on duplicates | First-time migration, append-only data, audit logs |
| Upsert | Insert new rows, update existing (matched by primary key / _id) |
Incremental sync, idempotent runs, ongoing CDC replication |
| Replace Collection (Drop & Insert) | Drop & recreate the target table / collection, then insert all rows | Full refresh, dev / staging re-seed, schema resets |
Once the initial snapshot completes, Debezium keeps the connection to the source's transaction log open and streams changes as they happen. Each Mongo target receives inserts, updates and deletes with sub-second latency in most deployments.
# Debezium connector properties (managed by VisuaLeaf UI)
name = users-pg-to-mongo
connector.class = io.debezium.connector.postgresql.PostgresConnector
database.hostname = db.internal
database.port = 5432
database.user = debezium
database.dbname = appdb
schema.include.list = public
table.include.list = public.users,public.orders
plugin.name = pgoutput
snapshot.mode = initial
publication.autocreate.mode = filtered
# VisuaLeaf-specific target settings
target.connection = mongo-prod
target.database = app
target.write.mode = upsert
target.match.key = id -> _id
Protect sensitive data during migration by applying masking transformations. Data masking allows you to export data for development, testing, or analytics while obscuring personally identifiable information (PII) and other sensitive fields.
| Mask Type | Description | Example |
|---|---|---|
| Redact | Replace with fixed placeholder | john@email.com → [REDACTED] |
| Partial Mask | Show first/last characters only | john@email.com → j***@***.com |
| Hash | One-way hash (SHA-256) | john@email.com → a8f5f167... |
| Randomize | Replace with random value of same type | 555-1234 → 382-9471 |
| Fake | Generate realistic fake data | John Smith → Jane Doe |
| Null | Replace with null/empty | secret123 → null |
Apply masking in the field transformation section of your export job:
// Redact completely
return '[REDACTED]';
// Partial mask email
return value.replace(/(.{1}).*@(.*)\.(.{2,})/, '$1***@***.$3');
// Hash value (consistent across runs)
return crypto.sha256(value);
// Randomize phone number
return '555-' + Math.floor(1000 + Math.random() * 9000);
// Null out field
return null;
| Field Type | Recommended Mask | Result |
|---|---|---|
| Partial mask | j***@***.com |
|
| Phone | Partial mask (last 4) | ***-***-1234 |
| SSN / ID | Hash or redact | ***-**-6789 or hash |
| Credit Card | Partial mask (last 4) | ****-****-****-1234 |
| Name | Fake data | Random realistic name |
| Address | Fake or redact | Random address or [REDACTED] |
| Password | Null or exclude | Don't export passwords |
Download and start managing your MongoDB databases with ease.
Download Free Trial