Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1a53a3c
Add migration tests and migration helper utility
renczesstefan May 11, 2026
232956d
Refactor and add migration helpers for streamlined operations
renczesstefan May 13, 2026
3566675
Refactor MigrationHelper to delegate logic to helper classes
renczesstefan May 18, 2026
ecefa55
[NAE-2433] Implement Migration Helper Integration for Engine 6.x
renczesstefan May 27, 2026
ba219b1
Remove unused `MongodbSerializer` class
renczesstefan May 27, 2026
f1f2cc0
[NAE-2433] Implement Migration Helper Integration for Engine 6.x
renczesstefan May 28, 2026
a40bf41
[NAE-2433] Implement Migration Helper Integration for Engine 6.x
renczesstefan May 28, 2026
a1f15a5
[NAE-2433] Implement Migration Helper Integration for Engine 6.x
renczesstefan May 28, 2026
c406aa7
[NAE-2433] Implement Migration Helper Integration for Engine 6.x
renczesstefan May 28, 2026
e2a0b7c
[NAE-2433] Implement Migration Helper Integration for Engine 6.x
renczesstefan May 28, 2026
b5b7fe7
[NAE-2433] Implement Migration Helper Integration for Engine 6.x
renczesstefan May 28, 2026
fd11930
Remove unused `Assert` import from `CaseMigrationHelper`
renczesstefan May 28, 2026
eed1e8d
Harden `CaseMigrationHelper` against null values in data field conver…
renczesstefan May 28, 2026
084a706
Fix null handling in `CaseMigrationHelper` and refine `MigrationTest`…
renczesstefan May 28, 2026
e3d12d9
- Introduce MigrationError, MigrationErrorPolicy, MigrationErrorHandl…
renczesstefan May 28, 2026
8fd6f81
- updated according to PR suggestions
renczesstefan May 29, 2026
6e34cf4
Make `changeDataFieldsValueFromTextToNumber` non-static and handle nu…
renczesstefan May 29, 2026
2e2229d
Pass `errorPolicy` explicitly in `changeDataFieldsValueFromTextToNumb…
renczesstefan May 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions docs/migration/migration_error_handling_quick_usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Migration Error Handling — Quick Usage

Use `MigrationErrorPolicy` to control what happens when a migration helper encounters an error.
``` groovy
import com.netgrif.application.engine.migration.model.MigrationErrorPolicy
```

## Available policies

``` groovy
MigrationErrorPolicy.continueOnError() // log/cache errors and continue
MigrationErrorPolicy.throwImmediately() // stop on first error
MigrationErrorPolicy.throwAfterLimit(10) // stop after 10 errors
MigrationErrorPolicy.throwAfterProcessing() // process all, then fail if errors exist
```

### Basic usage

``` groovy
migrationHelper.withErrorPolicy(MigrationErrorPolicy.throwAfterProcessing()) {
migrationHelper.updateAllCasesCursor({ Case useCase ->
// migration logic
})
}
```

### Continue migration and inspect errors

``` groovy
migrationHelper.clearErrors()

migrationHelper.withErrorPolicy(MigrationErrorPolicy.continueOnError()) {
migrationHelper.updateAllCasesCursor({ Case useCase ->
// migration logic
})
}

def errors = migrationHelper.popErrors()

errors.each { error ->
log.warn("${error.entityType} ${error.entityId}: ${error.message}", error.cause)
}
```

### Stop after a number of errors

``` groovy
migrationHelper.withErrorPolicy(MigrationErrorPolicy.throwAfterLimit(20)) {
migrationHelper.updateAllTasksCursor({ Task task ->
migrationHelper.elasticTaskIndex(task)
})
}
```

### Fail after full processing

``` groovy
import com.netgrif.application.engine.migration.throwable.MigrationErrorException

try {
migrationHelper.withErrorPolicy(MigrationErrorPolicy.throwAfterProcessing()) {
migrationHelper.updateAllCasesCursor({ Case useCase ->
// migration logic
})
}
} catch (MigrationErrorException e) {
log.error("Migration failed with ${e.errors.size()} errors")

e.errors.each { error ->
log.error("${error.entityType} ${error.entityId}: ${error.message}", error.cause)
}

throw e
}
```

### Error cache helpers

``` groovy
migrationHelper.clearErrors() // clears cached errors
migrationHelper.hasErrors() // true if errors exist
migrationHelper.getErrors() // returns errors without clearing
migrationHelper.popErrors() // returns errors and clears cache
```

### Recommended production pattern

``` groovy
migrationHelper.clearErrors()

migrationHelper.withErrorPolicy(MigrationErrorPolicy.throwAfterProcessing()) {
// migration logic
}
```
Use throwAfterProcessing() for most production migrations because it collects a full error report and fails only after all possible records are processed.

Large diffs are not rendered by default.

Loading
Loading