diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4528-oid-for-text.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4528-oid-for-text.yaml new file mode 100644 index 00000000000..5fcc0981953 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4528-oid-for-text.yaml @@ -0,0 +1,7 @@ +--- +type: fix +issue: 4528 +title: "Three database columns have been changed from type TEXT to type OID + when running in Postgres: + BT2_JOB_INSTANCE.PARAMS_JSON_LOB, BT2_JOB_INSTANCE.REPORT, and BT2_WORK_CHUNK.CHUNK_DATA. + This prevents VACUUM erasing binary objects that are still in use." diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java index c6335beccc0..a19232bfa0c 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java @@ -108,6 +108,18 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { .online(true) .withColumns("SEARCH_PID") .onlyAppliesToPlatforms(NON_AUTOMATIC_FK_INDEX_PLATFORMS); + + // fix Postgres clob types - that stupid oid driver problem is still there + // BT2_JOB_INSTANCE.PARAMS_JSON_LOB + version.onTable("BT2_JOB_INSTANCE") + .migratePostgresTextClobToBinaryClob("20230208.1", "PARAMS_JSON_LOB"); + // BT2_JOB_INSTANCE.REPORT + version.onTable("BT2_JOB_INSTANCE") + .migratePostgresTextClobToBinaryClob("20230208.2", "REPORT"); + // BT2_WORK_CHUNK.CHUNK_DATA + version.onTable("BT2_WORK_CHUNK") + .migratePostgresTextClobToBinaryClob("20230208.3", "CHUNK_DATA"); + } private void init620() { diff --git a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ColumnTypeToDriverTypeToSqlType.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ColumnTypeToDriverTypeToSqlType.java index 15eeb8efa28..0aa498f9f02 100644 --- a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ColumnTypeToDriverTypeToSqlType.java +++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ColumnTypeToDriverTypeToSqlType.java @@ -109,7 +109,7 @@ public final class ColumnTypeToDriverTypeToSqlType { setColumnType(ColumnTypeEnum.CLOB, DriverTypeEnum.MARIADB_10_1, "longtext"); setColumnType(ColumnTypeEnum.CLOB, DriverTypeEnum.MYSQL_5_7, "longtext"); setColumnType(ColumnTypeEnum.CLOB, DriverTypeEnum.ORACLE_12C, "clob"); - setColumnType(ColumnTypeEnum.CLOB, DriverTypeEnum.POSTGRES_9_4, "text"); + setColumnType(ColumnTypeEnum.CLOB, DriverTypeEnum.POSTGRES_9_4, "oid"); // the PG driver will write oid into a `text` column setColumnType(ColumnTypeEnum.CLOB, DriverTypeEnum.MSSQL_2012, "varchar(MAX)"); }