You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`SKIP_MISSING_REQUIRED` skips the record if required fields are missing. When `false`, default values for required fields must be configured in `src/config.js`
131
-
Logfiles are by default stored in `logs/migration.log`
132
-
It can be configured using the env variable `LOG_FILE`
133
-
Log levels(increasing level of information): `error`, `warn`, `info`, `debug`
134
-
Further migration configuration can also be done in `src/config.js`
154
+
155
+
`SKIP_MISSING_REQUIRED` skips the record if required fields are missing. When `false`, default values for required fields must be configured in `src/config.js`.
156
+
`MIGRATION_MODE` controls the migration strategy. Set to `full` for complete data loads or `incremental` for date-filtered updates. Defaults to `full`. See the `Incremental Updates` section below for detailed usage.
157
+
`INCREMENTAL_SINCE_DATE` specifies the cutoff date for incremental migrations (ISO 8601 format, e.g., `2024-01-15T00:00:00Z`). Only records with `updatedAt` or `updated` fields after this date are processed. Required when `MIGRATION_MODE=incremental`.
158
+
`INCREMENTAL_FIELDS` is an optional comma-separated list of field names (e.g., `status,updatedAt,name`) that restricts which fields are updated during incremental migrations. When omitted, all fields are updated. The fields `updatedAt` and `updatedBy` are always included. Useful for targeted updates like status changes or counter refreshes.
159
+
Logfiles are by default stored in `logs/migration.log`.
160
+
You can set a custom location with the `LOG_FILE` environment variable.
161
+
Log levels (in increasing verbosity): `error`, `warn`, `info`, `debug`.
162
+
Further migration configuration can also be done in `src/config.js`.
163
+
164
+
## Incremental Updates
165
+
166
+
Incremental updates let you run a full migration once and then keep the database in sync with smaller, targeted refreshes. After the initial load, you can filter subsequent runs to only process records changed after a specific date. The migrators handle both updates to existing rows and insertion of new records while leaving untouched data in place. This will help cut down on the time needed to migrate the data on the final cutover date.
167
+
168
+
### How It Works
169
+
1.**Date filtering**: Only records with `updatedAt` or `updated` values later than `INCREMENTAL_SINCE_DATE` are loaded into memory.
170
+
2.**Selective field updates**: When `INCREMENTAL_FIELDS` is set, only those fields are updated on matching database records; otherwise, all fields are considered for updates.
171
+
3.**Upsert behavior**: New records are inserted in full, while existing records receive partial or full updates based on your configuration.
172
+
173
+
All standard validation rules, dependency checks, and relational guarantees remain in effect while running in incremental mode.
174
+
175
+
### Configuration
176
+
-`MIGRATION_MODE`: Set to `incremental` to enable this workflow (defaults to `full`).
177
+
-`INCREMENTAL_SINCE_DATE`: ISO 8601 timestamp that defines the cutoff date (e.g., `2024-01-15T00:00:00Z`). Only records updated after this value are processed.
178
+
-`INCREMENTAL_FIELDS`: Optional comma-separated list to limit which fields are updated (e.g., `status,updatedAt,name`). When omitted, all fields are updated; when set, the tool automatically includes `updatedAt` and `updatedBy`.
179
+
180
+
### Limitations
181
+
- Records without `updatedAt` or `updated` fields will be skipped in incremental mode (a warning is logged).
182
+
- The `INCREMENTAL_FIELDS` configuration applies globally to all migrators; model-specific field lists are not currently supported.
183
+
- Deleted records in the source data are not removed from the database; incremental mode only handles updates and inserts.
184
+
- Dependency validation still requires related records to exist; ensure dependent models are included in the incremental run.
0 commit comments