Commit aeefa5b
fix(migration): v200 thread_entity guard, PostgreSQL jsonb cast, self-loop cycle detection (#27756)
* fix(migration): v200 thread_entity guard, PostgreSQL jsonb cast, self-loop cycle detection
- Add tableExists guard to migrateThreadTasksToTaskEntity so it skips safely when
thread_entity has been renamed to thread_entity_legacy by postDataMigration SQL,
preventing crashes on fresh installs and migration re-runs
- Fix PostgreSQL jsonb type mismatch in migrateSuggestionsToTaskEntity and
migrateLegacyActivityThreadsToActivityStream: JDBI binds String as varchar which
PostgreSQL rejects for jsonb columns; use ::jsonb cast when ConnectionType is POSTGRES
- Re-enable migrateThreadTasksToTaskEntity for MySQL (was commented out as workaround)
now that the tableExists guard makes it safe
- Fix hasCycleDFS in WorkflowDefinitionRepository to skip self-loop edges so
BPMN reassignment cycles (AssignedStage -> AssignedStage) are not flagged as cycles,
allowing IncidentLifecycleWorkflow to seed without error
- Fix initSeedDataFromResources in EntityRepository to continue seeding remaining
entities when one entity fails, instead of aborting the entire seed operation
- Add unit tests covering MySQL/PostgreSQL variants for all three migration methods,
tableExists guard, and jsonb cast behavior (13 tests total, all passing)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(migration): address review feedback on tableExists and jsonb cast tests
- Fix tableExists to use findFirst() instead of one(): one() throws on an
empty result set (0 rows from an existing but empty table), causing the
guard to incorrectly return false and log "table does not exist"
- Replace vacuous jsonb cast tests with direct insertTask reflection tests:
the previous tests mocked an empty thread list so insertTask was never
reached, making assertions trivially true regardless of cast logic; now
call insertTask directly via reflection so the ::jsonb cast path is
actually exercised for POSTGRES and absent for MYSQL
- Update tableExists mock stubs in tests from .one() to .findFirst()
to match the corrected implementation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Fix v200 migration: insert entity_relationship rows for migrated tasks
Thread tasks and suggestions migrated to task_entity were missing
entity_relationship rows for assignees, createdBy, and about — causing
the repository to return empty assignees and no createdBy in the API.
Added insertTaskLinkRelationships helper called after each task INSERT
in both migrateThreadTasksToTaskEntity and migrateSuggestionsToTaskEntity.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Fix v200 migration: UPSERT entity_relationship rows and handle thread_entity_legacy
- Replace INSERT IGNORE/ON CONFLICT DO NOTHING with UPSERT so stale
entity_relationship rows written by 1.12.x FeedRepository (toEntity='thread')
get corrected to toEntity='task' on PK conflict instead of being silently skipped
- Fall back to thread_entity_legacy when thread_entity is absent so subsequent
server starts (after post-DDL rename) still process thread tasks
- For tasks already in task_entity, still call insertTaskLinkRelationships instead
of skipping entirely, ensuring relationship rows are backfilled idempotently
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Fix v200 migration: null-safe createdBy lookup in alreadyExists backfill
Use threadJson.path("createdBy").asText("system") to avoid treating a
JSON null value as the literal string "null" which would cause lookupUserId
to fail and skip the CREATED entity_relationship row.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent a1e7086 commit aeefa5b
6 files changed
Lines changed: 436 additions & 38 deletions
File tree
- openmetadata-service/src
- main/java/org/openmetadata/service
- jdbi3
- migration
- mysql/v200
- postgres/v200
- utils/v200
- test/java/org/openmetadata/service/migration/utils/v200
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1228 | 1228 | | |
1229 | 1229 | | |
1230 | 1230 | | |
1231 | | - | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
1232 | 1241 | | |
1233 | 1242 | | |
1234 | 1243 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
350 | 353 | | |
351 | 354 | | |
352 | 355 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
openmetadata-service/src/main/java/org/openmetadata/service/migration/postgres/v200/Migration.java
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
0 commit comments