mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-27 18:05:00 +00:00
fix: handle postgres migration error (#13844)
* fix: handle postgres migration error * fix: removed MySQL comment
This commit is contained in:
parent
9d58b56a1c
commit
9d238d142a
@ -13,7 +13,9 @@ import org.openmetadata.service.Entity;
|
|||||||
import org.openmetadata.service.jdbi3.CollectionDAO;
|
import org.openmetadata.service.jdbi3.CollectionDAO;
|
||||||
import org.openmetadata.service.jdbi3.GlossaryTermRepository;
|
import org.openmetadata.service.jdbi3.GlossaryTermRepository;
|
||||||
import org.openmetadata.service.jdbi3.QueryRepository;
|
import org.openmetadata.service.jdbi3.QueryRepository;
|
||||||
|
import org.openmetadata.service.resources.databases.DatasourceConfig;
|
||||||
import org.openmetadata.service.util.JsonUtils;
|
import org.openmetadata.service.util.JsonUtils;
|
||||||
|
import org.postgresql.util.PGobject;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class MigrationUtil {
|
public class MigrationUtil {
|
||||||
@ -136,7 +138,15 @@ public class MigrationUtil {
|
|||||||
.mapToMap()
|
.mapToMap()
|
||||||
.forEach(
|
.forEach(
|
||||||
row -> {
|
row -> {
|
||||||
GlossaryTerm term = JsonUtils.readValue((String) row.get("json"), GlossaryTerm.class);
|
String jsonRow;
|
||||||
|
if (Boolean.TRUE.equals(DatasourceConfig.getInstance().isMySQL())) {
|
||||||
|
jsonRow = (String) row.get("json");
|
||||||
|
} else {
|
||||||
|
// Postgres stores JSON as a JSONB, so we can't just cast it as a string
|
||||||
|
PGobject pgObject = (PGobject) row.get("json");
|
||||||
|
jsonRow = pgObject.getValue();
|
||||||
|
}
|
||||||
|
GlossaryTerm term = JsonUtils.readValue(jsonRow, GlossaryTerm.class);
|
||||||
if (term.getStatus() == GlossaryTerm.Status.DRAFT) {
|
if (term.getStatus() == GlossaryTerm.Status.DRAFT) {
|
||||||
term.setStatus(GlossaryTerm.Status.APPROVED);
|
term.setStatus(GlossaryTerm.Status.APPROVED);
|
||||||
collectionDAO.glossaryTermDAO().update(term);
|
collectionDAO.glossaryTermDAO().update(term);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user