extends B
migrator.createMigrationTableIfRequired();
migrator.setDryRun(dryRun);
+ migrator.setRunHeavyweightSkippableTasks(runHeavyweight);
migrator.setNoColumnShrink(noColumnShrink);
String skipVersions = theCommandLine.getOptionValue(BaseFlywayMigrateDatabaseCommand.SKIP_VERSIONS);
addTasks(migrator, skipVersions);
diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml
index b6c73678960..45ecdebddca 100644
--- a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml
+++ b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-fhir-cli
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../pom.xml
diff --git a/hapi-fhir-cli/pom.xml b/hapi-fhir-cli/pom.xml
index 6745d62518b..2eb4c555392 100644
--- a/hapi-fhir-cli/pom.xml
+++ b/hapi-fhir-cli/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../pom.xml
diff --git a/hapi-fhir-client-okhttp/pom.xml b/hapi-fhir-client-okhttp/pom.xml
index 9a7ac810865..b2fa315c0ee 100644
--- a/hapi-fhir-client-okhttp/pom.xml
+++ b/hapi-fhir-client-okhttp/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-client/pom.xml b/hapi-fhir-client/pom.xml
index de0d7f14afe..b5667ad3e0c 100644
--- a/hapi-fhir-client/pom.xml
+++ b/hapi-fhir-client/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-converter/pom.xml b/hapi-fhir-converter/pom.xml
index 9883e898092..3cfc40c6258 100644
--- a/hapi-fhir-converter/pom.xml
+++ b/hapi-fhir-converter/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-dist/pom.xml b/hapi-fhir-dist/pom.xml
index 9e001be27ab..f008db1fd69 100644
--- a/hapi-fhir-dist/pom.xml
+++ b/hapi-fhir-dist/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../pom.xml
diff --git a/hapi-fhir-docs/pom.xml b/hapi-fhir-docs/pom.xml
index ba6c6912dbc..ab973c0f6b8 100644
--- a/hapi-fhir-docs/pom.xml
+++ b/hapi-fhir-docs/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_4_0/5926-fix-jpa-nullable-primitive-columns.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_4_0/5926-fix-jpa-nullable-primitive-columns.yaml
new file mode 100644
index 00000000000..a444a25f548
--- /dev/null
+++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_4_0/5926-fix-jpa-nullable-primitive-columns.yaml
@@ -0,0 +1,4 @@
+---
+type: fix
+issue: 5926
+title: "A number of columns in the JPA schema use primitive types (and therefore can never have a null value) but aren't marked as non-null."
diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_4_0/5926-skip-migrators-when-initializing.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_4_0/5926-skip-migrators-when-initializing.yaml
new file mode 100644
index 00000000000..cd3506ee7af
--- /dev/null
+++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_4_0/5926-skip-migrators-when-initializing.yaml
@@ -0,0 +1,7 @@
+---
+type: fix
+issue: 5926
+title: "A regression in HAPI FHIR 6.4.0 meant that ther JPA server schema migrator ran all tasks
+ even when the database was initially empty and the schema was being initialized by script.
+ This did not produce any incorrect results, but did impact the amount of time taken to initialize
+ an empty database. This has been corrected."
diff --git a/hapi-fhir-jacoco/pom.xml b/hapi-fhir-jacoco/pom.xml
index 7d35c5c03fa..7cc8d05502a 100644
--- a/hapi-fhir-jacoco/pom.xml
+++ b/hapi-fhir-jacoco/pom.xml
@@ -11,7 +11,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jaxrsserver-base/pom.xml b/hapi-fhir-jaxrsserver-base/pom.xml
index aa02e821f97..300c0cb720b 100644
--- a/hapi-fhir-jaxrsserver-base/pom.xml
+++ b/hapi-fhir-jaxrsserver-base/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpa/pom.xml b/hapi-fhir-jpa/pom.xml
index 145cdb4224f..5885d7a365e 100644
--- a/hapi-fhir-jpa/pom.xml
+++ b/hapi-fhir-jpa/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml
index d628e03ee5c..230c0a53a73 100644
--- a/hapi-fhir-jpaserver-base/pom.xml
+++ b/hapi-fhir-jpaserver-base/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/Batch2JobInstanceEntity.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/Batch2JobInstanceEntity.java
index bcf0a6cc0d9..3da31581d26 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/Batch2JobInstanceEntity.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/Batch2JobInstanceEntity.java
@@ -119,13 +119,13 @@ public class Batch2JobInstanceEntity implements Serializable {
@Column(name = "WORK_CHUNKS_PURGED", nullable = false)
private boolean myWorkChunksPurged;
- @Column(name = "PROGRESS_PCT")
+ @Column(name = "PROGRESS_PCT", nullable = false)
private double myProgress;
@Column(name = "ERROR_MSG", length = ERROR_MSG_MAX_LENGTH, nullable = true)
private String myErrorMessage;
- @Column(name = "ERROR_COUNT")
+ @Column(name = "ERROR_COUNT", nullable = false)
private int myErrorCount;
@Column(name = "EST_REMAINING", length = TIME_REMAINING_LENGTH, nullable = true)
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/Batch2WorkChunkEntity.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/Batch2WorkChunkEntity.java
index db60706f476..26bccd58bf9 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/Batch2WorkChunkEntity.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/Batch2WorkChunkEntity.java
@@ -138,6 +138,10 @@ public class Batch2WorkChunkEntity implements Serializable {
/**
* The number of times the work chunk has had its state set back to POLL_WAITING.
+ *
+ * TODO: Note that this column was added in 7.2.0, so it is nullable in order to
+ * account for existing rows that were added before the column was added. In
+ * the future we should make this non-null.
*/
@Column(name = "POLL_ATTEMPTS", nullable = true)
private Integer myPollAttempts;
@@ -145,7 +149,9 @@ public class Batch2WorkChunkEntity implements Serializable {
/**
* Default constructor for Hibernate.
*/
- public Batch2WorkChunkEntity() {}
+ public Batch2WorkChunkEntity() {
+ myPollAttempts = 0;
+ }
/**
* Projection constructor for no-data path.
@@ -184,7 +190,7 @@ public class Batch2WorkChunkEntity implements Serializable {
myRecordsProcessed = theRecordsProcessed;
myWarningMessage = theWarningMessage;
myNextPollTime = theNextPollTime;
- myPollAttempts = thePollAttempts;
+ myPollAttempts = thePollAttempts != null ? thePollAttempts : 0;
}
public static Batch2WorkChunkEntity fromWorkChunk(WorkChunk theWorkChunk) {
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/HapiFhirEnversRevision.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/HapiFhirEnversRevision.java
index 3a930be0e27..68c7ac12f7e 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/HapiFhirEnversRevision.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/HapiFhirEnversRevision.java
@@ -58,7 +58,7 @@ public class HapiFhirEnversRevision implements Serializable {
@SequenceGenerator(name = "SEQ_HFJ_REVINFO", sequenceName = "SEQ_HFJ_REVINFO")
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_HFJ_REVINFO")
@RevisionNumber
- @Column(name = "REV")
+ @Column(name = "REV", nullable = false)
private long myRev;
@RevisionTimestamp
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermConcept.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermConcept.java
index d238278bcfe..5f056979fea 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermConcept.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermConcept.java
@@ -117,11 +117,12 @@ public class TermConcept implements Serializable {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(
name = "CODESYSTEM_PID",
+ nullable = false,
referencedColumnName = "PID",
foreignKey = @ForeignKey(name = "FK_CONCEPT_PID_CS_PID"))
private TermCodeSystemVersion myCodeSystem;
- @Column(name = "CODESYSTEM_PID", insertable = false, updatable = false)
+ @Column(name = "CODESYSTEM_PID", insertable = false, updatable = false, nullable = false)
@GenericField(name = "myCodeSystemVersionPid")
private long myCodeSystemVersionPid;
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 0db112c60fd..7bcebb19fda 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
@@ -25,7 +25,6 @@ import ca.uhn.fhir.jpa.entity.BulkImportJobEntity;
import ca.uhn.fhir.jpa.entity.Search;
import ca.uhn.fhir.jpa.migrate.DriverTypeEnum;
import ca.uhn.fhir.jpa.migrate.taskdef.ArbitrarySqlTask;
-import ca.uhn.fhir.jpa.migrate.taskdef.BaseTask;
import ca.uhn.fhir.jpa.migrate.taskdef.CalculateHashesTask;
import ca.uhn.fhir.jpa.migrate.taskdef.CalculateOrdinalDatesTask;
import ca.uhn.fhir.jpa.migrate.taskdef.ColumnTypeEnum;
@@ -33,6 +32,7 @@ import ca.uhn.fhir.jpa.migrate.taskdef.ForceIdMigrationCopyTask;
import ca.uhn.fhir.jpa.migrate.taskdef.ForceIdMigrationFixTask;
import ca.uhn.fhir.jpa.migrate.tasks.api.BaseMigrationTasks;
import ca.uhn.fhir.jpa.migrate.tasks.api.Builder;
+import ca.uhn.fhir.jpa.migrate.tasks.api.TaskFlagEnum;
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
import ca.uhn.fhir.jpa.model.entity.BaseResourceIndexedSearchParam;
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
@@ -135,6 +135,121 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
.toColumn("RES_ID")
.references("HFJ_RESOURCE", "RES_ID");
}
+
+ /*
+ * Make a bunch of columns non-nullable. Note that we won't actually apply this migration
+ * on the live system as it would take a loooooong time to execute these on heavily loaded
+ * databases.
+ */
+ // Skipping numbers 20240601.1 and 20240601.2 as they were found to not
+ // be needed during code review.
+ version.onTable("HFJ_RESOURCE")
+ .modifyColumn("20240601.3", "SP_HAS_LINKS")
+ .nonNullable()
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("HFJ_RESOURCE")
+ .modifyColumn("20240601.4", "SP_COORDS_PRESENT")
+ .nonNullable()
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("HFJ_RESOURCE")
+ .modifyColumn("20240601.5", "SP_DATE_PRESENT")
+ .nonNullable()
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("HFJ_RESOURCE")
+ .modifyColumn("20240601.6", "SP_NUMBER_PRESENT")
+ .nonNullable()
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("HFJ_RESOURCE")
+ .modifyColumn("20240601.7", "SP_QUANTITY_PRESENT")
+ .nonNullable()
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("HFJ_RESOURCE")
+ .modifyColumn("20240601.8", "SP_QUANTITY_NRML_PRESENT")
+ .nonNullable()
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("HFJ_RESOURCE")
+ .modifyColumn("20240601.9", "SP_STRING_PRESENT")
+ .nonNullable()
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("HFJ_RESOURCE")
+ .modifyColumn("20240601.10", "SP_TOKEN_PRESENT")
+ .nonNullable()
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("HFJ_RESOURCE")
+ .modifyColumn("20240601.11", "SP_URI_PRESENT")
+ .nonNullable()
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("HFJ_RESOURCE")
+ .modifyColumn("20240601.12", "RES_VER")
+ .nonNullable()
+ .withType(ColumnTypeEnum.LONG)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("TRM_CONCEPT")
+ .modifyColumn("20240601.13", "CODESYSTEM_PID")
+ .nonNullable()
+ .withType(ColumnTypeEnum.LONG)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("BT2_JOB_INSTANCE")
+ .modifyColumn("20240601.14", "PROGRESS_PCT")
+ .nonNullable()
+ .withType(ColumnTypeEnum.DOUBLE)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("BT2_JOB_INSTANCE")
+ .modifyColumn("20240601.15", "ERROR_COUNT")
+ .nonNullable()
+ .withType(ColumnTypeEnum.INT)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+ version.onTable("HFJ_BINARY_STORAGE_BLOB")
+ .modifyColumn("20240601.16", "BLOB_SIZE")
+ .nonNullable()
+ .withType(ColumnTypeEnum.LONG)
+ .heavyweightSkipByDefault()
+ .failureAllowed();
+
+ /*
+ * Add RES_ID to two indexes on HFJ_RES_VER which support history operations.
+ * This makes server and type level _history work properly on large databases
+ * on postgres. These are both marked as heavyweightSkipByDefault because the
+ * necessary reindexing would be very expensive for a rarely used FHIR feature.
+ */
+ version.onTable("HFJ_RES_VER")
+ .dropIndex("20240601.17", "IDX_RESVER_TYPE_DATE")
+ .heavyweightSkipByDefault();
+ version.onTable("HFJ_RES_VER")
+ .addIndex("20240601.18", "IDX_RESVER_TYPE_DATE")
+ .unique(false)
+ .withColumns("RES_TYPE", "RES_UPDATED", "RES_ID")
+ .heavyweightSkipByDefault();
+ version.onTable("HFJ_RES_VER")
+ .dropIndex("20240601.19", "IDX_RESVER_DATE")
+ .heavyweightSkipByDefault();
+ version.onTable("HFJ_RES_VER")
+ .addIndex("20240601.20", "IDX_RESVER_DATE")
+ .unique(false)
+ .withColumns("RES_UPDATED", "RES_ID")
+ .heavyweightSkipByDefault();
}
protected void init720() {
@@ -162,15 +277,15 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
binaryStorageBlobTable
.renameColumn("20240404.1", "BLOB_ID", "CONTENT_ID")
.getLastAddedTask()
- .ifPresent(BaseTask::doNothing);
+ .ifPresent(t -> t.addFlag(TaskFlagEnum.DO_NOTHING));
binaryStorageBlobTable
.renameColumn("20240404.2", "BLOB_SIZE", "CONTENT_SIZE")
.getLastAddedTask()
- .ifPresent(BaseTask::doNothing);
+ .ifPresent(t -> t.addFlag(TaskFlagEnum.DO_NOTHING));
binaryStorageBlobTable
.renameColumn("20240404.3", "BLOB_HASH", "CONTENT_HASH")
.getLastAddedTask()
- .ifPresent(BaseTask::doNothing);
+ .ifPresent(t -> t.addFlag(TaskFlagEnum.DO_NOTHING));
binaryStorageBlobTable
.modifyColumn("20240404.4", "BLOB_DATA")
@@ -262,7 +377,8 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
// Move forced_id constraints to hfj_resource and the new fhir_id column
// Note: we leave the HFJ_FORCED_ID.IDX_FORCEDID_TYPE_FID index in place to support old writers for a while.
- version.addTask(new ForceIdMigrationCopyTask(version.getRelease(), "20231018.1").setDoNothing(true));
+ version.addTask(
+ new ForceIdMigrationCopyTask(version.getRelease(), "20231018.1").addFlag(TaskFlagEnum.DO_NOTHING));
Builder.BuilderWithTableName hfjResource = version.onTable("HFJ_RESOURCE");
// commented out to make numeric space for the fix task below.
@@ -331,7 +447,8 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
}
// This fix was bad for MSSQL, it has been set to do nothing.
- version.addTask(new ForceIdMigrationFixTask(version.getRelease(), "20231213.1").setDoNothing(true));
+ version.addTask(
+ new ForceIdMigrationFixTask(version.getRelease(), "20231213.1").addFlag(TaskFlagEnum.DO_NOTHING));
// This fix will work for MSSQL or Oracle.
version.addTask(new ForceIdMigrationFixTask(version.getRelease(), "20231222.1"));
@@ -814,8 +931,8 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
version.onTable("HFJ_RES_VER")
.modifyColumn("20230421.1", "RES_TEXT_VC")
.nullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.TEXT);
+ .withType(ColumnTypeEnum.TEXT)
+ .failureAllowed();
{
// add hash_norm to res_id to speed up joins on a second string.
@@ -1751,8 +1868,8 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
version.onTable("HFJ_RES_LINK")
.modifyColumn("20210505.1", "SRC_PATH")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 500);
+ .withType(ColumnTypeEnum.STRING, 500)
+ .failureAllowed();
}
private void init530() {
@@ -1813,8 +1930,8 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
quantityTable
.modifyColumn("20210116.1", "SP_VALUE")
.nullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.DOUBLE);
+ .withType(ColumnTypeEnum.DOUBLE)
+ .failureAllowed();
// HFJ_RES_LINK
version.onTable("HFJ_RES_LINK")
@@ -2011,8 +2128,8 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
version.onTable("HFJ_RES_VER")
.modifyColumn("20200220.1", "RES_ID")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.LONG);
+ .withType(ColumnTypeEnum.LONG)
+ .failureAllowed();
//
// Drop unused column
@@ -2168,38 +2285,38 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
version.onTable("HFJ_SPIDX_STRING")
.modifyColumn("20200420.36", "SP_MISSING")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.BOOLEAN);
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_COORDS")
.modifyColumn("20200420.37", "SP_MISSING")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.BOOLEAN);
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_NUMBER")
.modifyColumn("20200420.38", "SP_MISSING")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.BOOLEAN);
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_TOKEN")
.modifyColumn("20200420.39", "SP_MISSING")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.BOOLEAN);
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_DATE")
.modifyColumn("20200420.40", "SP_MISSING")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.BOOLEAN);
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_URI")
.modifyColumn("20200420.41", "SP_MISSING")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.BOOLEAN);
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_QUANTITY")
.modifyColumn("20200420.42", "SP_MISSING")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.BOOLEAN);
+ .withType(ColumnTypeEnum.BOOLEAN)
+ .failureAllowed();
// Add support for integer comparisons during day-precision date search.
Builder.BuilderWithTableName spidxDate = version.onTable("HFJ_SPIDX_DATE");
@@ -2309,38 +2426,38 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
version.onTable("HFJ_SPIDX_NUMBER")
.modifyColumn("20190920.1", "RES_ID")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.LONG);
+ .withType(ColumnTypeEnum.LONG)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_COORDS")
.modifyColumn("20190920.2", "RES_ID")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.LONG);
+ .withType(ColumnTypeEnum.LONG)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_TOKEN")
.modifyColumn("20190920.3", "RES_ID")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.LONG);
+ .withType(ColumnTypeEnum.LONG)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_STRING")
.modifyColumn("20190920.4", "RES_ID")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.LONG);
+ .withType(ColumnTypeEnum.LONG)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_DATE")
.modifyColumn("20190920.5", "RES_ID")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.LONG);
+ .withType(ColumnTypeEnum.LONG)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_QUANTITY")
.modifyColumn("20190920.6", "RES_ID")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.LONG);
+ .withType(ColumnTypeEnum.LONG)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_URI")
.modifyColumn("20190920.7", "RES_ID")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.LONG);
+ .withType(ColumnTypeEnum.LONG)
+ .failureAllowed();
// HFJ_SEARCH
version.onTable("HFJ_SEARCH")
@@ -2469,33 +2586,33 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
version.onTable("HFJ_RESOURCE")
.modifyColumn("20191002.1", "RES_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 40);
+ .withType(ColumnTypeEnum.STRING, 40)
+ .failureAllowed();
version.onTable("HFJ_RES_VER")
.modifyColumn("20191002.2", "RES_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 40);
+ .withType(ColumnTypeEnum.STRING, 40)
+ .failureAllowed();
version.onTable("HFJ_HISTORY_TAG")
.modifyColumn("20191002.3", "RES_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 40);
+ .withType(ColumnTypeEnum.STRING, 40)
+ .failureAllowed();
version.onTable("HFJ_RES_LINK")
.modifyColumn("20191002.4", "SOURCE_RESOURCE_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 40);
+ .withType(ColumnTypeEnum.STRING, 40)
+ .failureAllowed();
version.onTable("HFJ_RES_LINK")
.modifyColumn("20191002.5", "TARGET_RESOURCE_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 40);
+ .withType(ColumnTypeEnum.STRING, 40)
+ .failureAllowed();
version.onTable("HFJ_RES_TAG")
.modifyColumn("20191002.6", "RES_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 40);
+ .withType(ColumnTypeEnum.STRING, 40)
+ .failureAllowed();
// TermConceptDesignation
version.startSectionWithMessage("Processing table: TRM_CONCEPT_DESIG");
@@ -2765,18 +2882,18 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
version.onTable("HFJ_SPIDX_COORDS")
.modifyColumn("20190814.9", "RES_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 100);
+ .withType(ColumnTypeEnum.STRING, 100)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_DATE")
.modifyColumn("20190814.10", "RES_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 100);
+ .withType(ColumnTypeEnum.STRING, 100)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_STRING")
.modifyColumn("20190814.11", "RES_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 100);
+ .withType(ColumnTypeEnum.STRING, 100)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_STRING")
.addColumn("20190814.12", "HASH_IDENTITY")
.nullable()
@@ -2788,50 +2905,50 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
version.onTable("HFJ_SPIDX_COORDS")
.modifyColumn("20190814.14", "RES_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 100);
+ .withType(ColumnTypeEnum.STRING, 100)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_QUANTITY")
.modifyColumn("20190814.15", "RES_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 100);
+ .withType(ColumnTypeEnum.STRING, 100)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_QUANTITY").dropColumn("20190814.16", "HASH_UNITS_AND_VALPREFIX");
version.onTable("HFJ_SPIDX_QUANTITY").dropColumn("20190814.17", "HASH_VALPREFIX");
version.onTable("HFJ_SPIDX_NUMBER")
.modifyColumn("20190814.18", "RES_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 100);
+ .withType(ColumnTypeEnum.STRING, 100)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_TOKEN")
.modifyColumn("20190814.19", "RES_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 100);
+ .withType(ColumnTypeEnum.STRING, 100)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_URI")
.modifyColumn("20190814.20", "RES_TYPE")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 100);
+ .withType(ColumnTypeEnum.STRING, 100)
+ .failureAllowed();
version.onTable("HFJ_SPIDX_URI")
.modifyColumn("20190814.21", "SP_URI")
.nullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 254);
+ .withType(ColumnTypeEnum.STRING, 254)
+ .failureAllowed();
version.onTable("TRM_CODESYSTEM")
.modifyColumn("20190814.22", "CODE_SYSTEM_URI")
.nonNullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 200);
+ .withType(ColumnTypeEnum.STRING, 200)
+ .failureAllowed();
version.onTable("TRM_CODESYSTEM")
.modifyColumn("20190814.23", "CS_NAME")
.nullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 200);
+ .withType(ColumnTypeEnum.STRING, 200)
+ .failureAllowed();
version.onTable("TRM_CODESYSTEM_VER")
.modifyColumn("20190814.24", "CS_VERSION_ID")
.nullable()
- .failureAllowed()
- .withType(ColumnTypeEnum.STRING, 200);
+ .withType(ColumnTypeEnum.STRING, 200)
+ .failureAllowed();
}
private void init360() { // 20180918 - 20181112
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/reindex/InstanceReindexServiceImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/reindex/InstanceReindexServiceImpl.java
index 8a69d6ef8e0..aeb8b9e31cd 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/reindex/InstanceReindexServiceImpl.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/reindex/InstanceReindexServiceImpl.java
@@ -524,8 +524,12 @@ public class InstanceReindexServiceImpl implements IInstanceReindexService {
String theParamTypeName) {
Parameters.ParametersParameterComponent retVal =
super.addIndexValue(theAction, theParent, theParam, theParamTypeName);
- retVal.addPart().setName("Latitude").setValue(new DecimalType(theParam.getLatitude()));
- retVal.addPart().setName("Longitude").setValue(new DecimalType(theParam.getLongitude()));
+ if (theParam.getLatitude() != null) {
+ retVal.addPart().setName("Latitude").setValue(new DecimalType(theParam.getLatitude()));
+ }
+ if (theParam.getLongitude() != null) {
+ retVal.addPart().setName("Longitude").setValue(new DecimalType(theParam.getLongitude()));
+ }
return retVal;
}
}
diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml b/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml
index e3ba27996ee..f0f55e9506f 100644
--- a/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml
+++ b/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-hfql/pom.xml b/hapi-fhir-jpaserver-hfql/pom.xml
index 2ae9ad02678..aaa57b40118 100644
--- a/hapi-fhir-jpaserver-hfql/pom.xml
+++ b/hapi-fhir-jpaserver-hfql/pom.xml
@@ -3,7 +3,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-ips/pom.xml b/hapi-fhir-jpaserver-ips/pom.xml
index 88e32f7e2d6..2aea1bf2f19 100644
--- a/hapi-fhir-jpaserver-ips/pom.xml
+++ b/hapi-fhir-jpaserver-ips/pom.xml
@@ -3,7 +3,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-mdm/pom.xml b/hapi-fhir-jpaserver-mdm/pom.xml
index 669f52ea6ba..7a7c9f7ab64 100644
--- a/hapi-fhir-jpaserver-mdm/pom.xml
+++ b/hapi-fhir-jpaserver-mdm/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-model/pom.xml b/hapi-fhir-jpaserver-model/pom.xml
index 1df82dac9f4..c453a3c30ab 100644
--- a/hapi-fhir-jpaserver-model/pom.xml
+++ b/hapi-fhir-jpaserver-model/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/BinaryStorageEntity.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/BinaryStorageEntity.java
index c6b046e0bff..f6d77040763 100644
--- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/BinaryStorageEntity.java
+++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/BinaryStorageEntity.java
@@ -45,7 +45,7 @@ public class BinaryStorageEntity {
@Column(name = "RESOURCE_ID", length = 100, nullable = false)
private String myResourceId;
- @Column(name = "BLOB_SIZE", nullable = true)
+ @Column(name = "BLOB_SIZE", nullable = false)
private long mySize;
@Column(name = "CONTENT_TYPE", nullable = false, length = 100)
diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceHistoryTable.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceHistoryTable.java
index 6348ce579b3..8ef37d8cdca 100644
--- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceHistoryTable.java
+++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceHistoryTable.java
@@ -60,9 +60,9 @@ import java.util.Collection;
columnNames = {"RES_ID", "RES_VER"})
},
indexes = {
- @Index(name = "IDX_RESVER_TYPE_DATE", columnList = "RES_TYPE,RES_UPDATED"),
+ @Index(name = "IDX_RESVER_TYPE_DATE", columnList = "RES_TYPE,RES_UPDATED,RES_ID"),
@Index(name = "IDX_RESVER_ID_DATE", columnList = "RES_ID,RES_UPDATED"),
- @Index(name = "IDX_RESVER_DATE", columnList = "RES_UPDATED")
+ @Index(name = "IDX_RESVER_DATE", columnList = "RES_UPDATED,RES_ID")
})
public class ResourceHistoryTable extends BaseHasResource implements Serializable {
public static final String IDX_RESVER_ID_VER = "IDX_RESVER_ID_VER";
diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceIndexedComboStringUnique.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceIndexedComboStringUnique.java
index 830fc6270aa..e61941cb611 100644
--- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceIndexedComboStringUnique.java
+++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceIndexedComboStringUnique.java
@@ -135,12 +135,14 @@ public class ResourceIndexedComboStringUnique extends BasePartitionable
myIndexString = theIndexString;
}
+ @Override
public ResourceTable getResource() {
return myResource;
}
+ @Override
public void setResource(ResourceTable theResource) {
- Validate.notNull(theResource);
+ Validate.notNull(theResource, "theResource must not be null");
myResource = theResource;
}
diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceIndexedSearchParamCoords.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceIndexedSearchParamCoords.java
index 40718b09df8..a66e5f6f564 100644
--- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceIndexedSearchParamCoords.java
+++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceIndexedSearchParamCoords.java
@@ -21,6 +21,7 @@ package ca.uhn.fhir.jpa.model.entity;
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
import ca.uhn.fhir.model.api.IQueryParameterType;
+import jakarta.annotation.Nullable;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Entity;
@@ -56,13 +57,11 @@ public class ResourceIndexedSearchParamCoords extends BaseResourceIndexedSearchP
private static final long serialVersionUID = 1L;
- @Column(name = "SP_LATITUDE")
- // @FullTextField
- public double myLatitude;
+ @Column(name = "SP_LATITUDE", nullable = true)
+ public Double myLatitude;
- @Column(name = "SP_LONGITUDE")
- // @FullTextField
- public double myLongitude;
+ @Column(name = "SP_LONGITUDE", nullable = true)
+ public Double myLongitude;
@Id
@SequenceGenerator(name = "SEQ_SPIDX_COORDS", sequenceName = "SEQ_SPIDX_COORDS")
@@ -162,7 +161,8 @@ public class ResourceIndexedSearchParamCoords extends BaseResourceIndexedSearchP
myId = theId;
}
- public double getLatitude() {
+ @Nullable
+ public Double getLatitude() {
return myLatitude;
}
@@ -171,7 +171,8 @@ public class ResourceIndexedSearchParamCoords extends BaseResourceIndexedSearchP
return this;
}
- public double getLongitude() {
+ @Nullable
+ public Double getLongitude() {
return myLongitude;
}
diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java
index 39f85198aec..e897ae71786 100644
--- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java
+++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java
@@ -142,7 +142,7 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
@OptimisticLock(excluded = true)
private String myHashSha256;
- @Column(name = "SP_HAS_LINKS")
+ @Column(name = "SP_HAS_LINKS", nullable = false)
@OptimisticLock(excluded = true)
private boolean myHasLinks;
@@ -203,7 +203,7 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
@OptimisticLock(excluded = true)
private Collection myParamsCoords;
- @Column(name = "SP_COORDS_PRESENT")
+ @Column(name = "SP_COORDS_PRESENT", nullable = false)
@OptimisticLock(excluded = true)
private boolean myParamsCoordsPopulated;
@@ -215,7 +215,7 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
@OptimisticLock(excluded = true)
private Collection myParamsDate;
- @Column(name = "SP_DATE_PRESENT")
+ @Column(name = "SP_DATE_PRESENT", nullable = false)
@OptimisticLock(excluded = true)
private boolean myParamsDatePopulated;
@@ -227,7 +227,7 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
orphanRemoval = false)
private Collection myParamsNumber;
- @Column(name = "SP_NUMBER_PRESENT")
+ @Column(name = "SP_NUMBER_PRESENT", nullable = false)
@OptimisticLock(excluded = true)
private boolean myParamsNumberPopulated;
@@ -239,7 +239,7 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
@OptimisticLock(excluded = true)
private Collection myParamsQuantity;
- @Column(name = "SP_QUANTITY_PRESENT")
+ @Column(name = "SP_QUANTITY_PRESENT", nullable = false)
@OptimisticLock(excluded = true)
private boolean myParamsQuantityPopulated;
@@ -260,7 +260,7 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
* NOTE : use Boolean class instead of boolean primitive, in order to set the existing rows to null
* since 5.3.0
*/
- @Column(name = "SP_QUANTITY_NRML_PRESENT")
+ @Column(name = "SP_QUANTITY_NRML_PRESENT", nullable = false)
@OptimisticLock(excluded = true)
private Boolean myParamsQuantityNormalizedPopulated = Boolean.FALSE;
@@ -272,7 +272,7 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
@OptimisticLock(excluded = true)
private Collection myParamsString;
- @Column(name = "SP_STRING_PRESENT")
+ @Column(name = "SP_STRING_PRESENT", nullable = false)
@OptimisticLock(excluded = true)
private boolean myParamsStringPopulated;
@@ -284,7 +284,7 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
@OptimisticLock(excluded = true)
private Collection myParamsToken;
- @Column(name = "SP_TOKEN_PRESENT")
+ @Column(name = "SP_TOKEN_PRESENT", nullable = false)
@OptimisticLock(excluded = true)
private boolean myParamsTokenPopulated;
@@ -296,7 +296,7 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
@OptimisticLock(excluded = true)
private Collection myParamsUri;
- @Column(name = "SP_URI_PRESENT")
+ @Column(name = "SP_URI_PRESENT", nullable = false)
@OptimisticLock(excluded = true)
private boolean myParamsUriPopulated;
@@ -404,7 +404,7 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
private Boolean mySearchUrlPresent = false;
@Version
- @Column(name = "RES_VER")
+ @Column(name = "RES_VER", nullable = false)
private long myVersion;
@OneToMany(mappedBy = "myResourceTable", fetch = FetchType.LAZY)
diff --git a/hapi-fhir-jpaserver-searchparam/pom.xml b/hapi-fhir-jpaserver-searchparam/pom.xml
index 675432baedc..7199a9ad0bc 100755
--- a/hapi-fhir-jpaserver-searchparam/pom.xml
+++ b/hapi-fhir-jpaserver-searchparam/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-subscription/pom.xml b/hapi-fhir-jpaserver-subscription/pom.xml
index 928e4754d88..3840df8a715 100644
--- a/hapi-fhir-jpaserver-subscription/pom.xml
+++ b/hapi-fhir-jpaserver-subscription/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-test-dstu2/pom.xml b/hapi-fhir-jpaserver-test-dstu2/pom.xml
index 6d526c2967a..ed44b54b06d 100644
--- a/hapi-fhir-jpaserver-test-dstu2/pom.xml
+++ b/hapi-fhir-jpaserver-test-dstu2/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-test-dstu3/pom.xml b/hapi-fhir-jpaserver-test-dstu3/pom.xml
index 75747b68a7f..ebf988b81f9 100644
--- a/hapi-fhir-jpaserver-test-dstu3/pom.xml
+++ b/hapi-fhir-jpaserver-test-dstu3/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-test-r4/pom.xml b/hapi-fhir-jpaserver-test-r4/pom.xml
index 9ac14b62183..a05fcda4c4b 100644
--- a/hapi-fhir-jpaserver-test-r4/pom.xml
+++ b/hapi-fhir-jpaserver-test-r4/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-test-r4b/pom.xml b/hapi-fhir-jpaserver-test-r4b/pom.xml
index 75d284dddda..5ad8360e422 100644
--- a/hapi-fhir-jpaserver-test-r4b/pom.xml
+++ b/hapi-fhir-jpaserver-test-r4b/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-test-r5/pom.xml b/hapi-fhir-jpaserver-test-r5/pom.xml
index d8ed3a11ea3..0585c6f87aa 100644
--- a/hapi-fhir-jpaserver-test-r5/pom.xml
+++ b/hapi-fhir-jpaserver-test-r5/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-test-utilities/pom.xml b/hapi-fhir-jpaserver-test-utilities/pom.xml
index 323a1e00051..ea643589d1b 100644
--- a/hapi-fhir-jpaserver-test-utilities/pom.xml
+++ b/hapi-fhir-jpaserver-test-utilities/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml
index da796517f5b..174a429705a 100644
--- a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml
+++ b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../pom.xml
diff --git a/hapi-fhir-server-cds-hooks/pom.xml b/hapi-fhir-server-cds-hooks/pom.xml
index 3bef5a5c5df..adbe430ad0f 100644
--- a/hapi-fhir-server-cds-hooks/pom.xml
+++ b/hapi-fhir-server-cds-hooks/pom.xml
@@ -7,7 +7,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-server-mdm/pom.xml b/hapi-fhir-server-mdm/pom.xml
index bddca577b5b..b7e48476ad6 100644
--- a/hapi-fhir-server-mdm/pom.xml
+++ b/hapi-fhir-server-mdm/pom.xml
@@ -7,7 +7,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-server-openapi/pom.xml b/hapi-fhir-server-openapi/pom.xml
index c1f03e6eca8..c9f0f0a14c7 100644
--- a/hapi-fhir-server-openapi/pom.xml
+++ b/hapi-fhir-server-openapi/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-server/pom.xml b/hapi-fhir-server/pom.xml
index bc844b33a29..84c16998ebc 100644
--- a/hapi-fhir-server/pom.xml
+++ b/hapi-fhir-server/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml
index a4eb90d2992..288431d981c 100644
--- a/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml
+++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml
@@ -7,7 +7,7 @@
hapi-fhir-serviceloaders
ca.uhn.hapi.fhir
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../pom.xml
diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml
index 614cfc967b7..46a455edf0a 100644
--- a/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml
+++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml
@@ -7,7 +7,7 @@
hapi-fhir-serviceloaders
ca.uhn.hapi.fhir
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../pom.xml
@@ -21,7 +21,7 @@
ca.uhn.hapi.fhir
hapi-fhir-caching-api
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml
index 322eb544e6c..1629077b0fd 100644
--- a/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml
+++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml
@@ -7,7 +7,7 @@
hapi-fhir-serviceloaders
ca.uhn.hapi.fhir
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../pom.xml
diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml
index 782403fec87..d805e44028c 100644
--- a/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml
+++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml
@@ -7,7 +7,7 @@
hapi-fhir
ca.uhn.hapi.fhir
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../../pom.xml
diff --git a/hapi-fhir-serviceloaders/pom.xml b/hapi-fhir-serviceloaders/pom.xml
index 9a56ecfd799..87384aa0ef1 100644
--- a/hapi-fhir-serviceloaders/pom.xml
+++ b/hapi-fhir-serviceloaders/pom.xml
@@ -5,7 +5,7 @@
hapi-deployable-pom
ca.uhn.hapi.fhir
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml
index 3e2354e4901..e49c57173a6 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml
index 12079ac6303..b042bb09416 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir-spring-boot-samples
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
hapi-fhir-spring-boot-sample-client-apache
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml
index f7631efb99b..0d55565aa40 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir-spring-boot-samples
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml
index e7be98afcd8..9776f578481 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir-spring-boot-samples
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml
index 3172d609d8a..b83b51ba012 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir-spring-boot
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml
index ff62090b5d1..9c63563684f 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-spring-boot/pom.xml b/hapi-fhir-spring-boot/pom.xml
index afb870730a1..aa18dfb90ff 100644
--- a/hapi-fhir-spring-boot/pom.xml
+++ b/hapi-fhir-spring-boot/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../pom.xml
diff --git a/hapi-fhir-sql-migrate/pom.xml b/hapi-fhir-sql-migrate/pom.xml
index ce8c9c06fe6..a7cc58ab8fe 100644
--- a/hapi-fhir-sql-migrate/pom.xml
+++ b/hapi-fhir-sql-migrate/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 7.3.7-SNAPSHOT
+ 7.3.8-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/HapiMigrator.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/HapiMigrator.java
index dd8afdce598..17ee41c8032 100644
--- a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/HapiMigrator.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/HapiMigrator.java
@@ -23,6 +23,7 @@ import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.jpa.migrate.dao.HapiMigrationDao;
import ca.uhn.fhir.jpa.migrate.taskdef.BaseTask;
import ca.uhn.fhir.jpa.migrate.taskdef.InitializeSchemaTask;
+import ca.uhn.fhir.jpa.migrate.tasks.api.TaskFlagEnum;
import ca.uhn.fhir.system.HapiSystemProperties;
import ca.uhn.fhir.util.StopWatch;
import com.google.common.annotations.VisibleForTesting;
@@ -44,6 +45,7 @@ public class HapiMigrator {
private static final Logger ourLog = LoggerFactory.getLogger(HapiMigrator.class);
private final MigrationTaskList myTaskList = new MigrationTaskList();
private boolean myDryRun;
+ private boolean myRunHeavyweightSkippableTasks;
private boolean myNoColumnShrink;
private final DriverTypeEnum myDriverType;
private final DataSource myDataSource;
@@ -69,6 +71,24 @@ public class HapiMigrator {
myDryRun = theDryRun;
}
+ /**
+ * Should we run the tasks marked with {@link ca.uhn.fhir.jpa.migrate.tasks.api.TaskFlagEnum#HEAVYWEIGHT_SKIP_BY_DEFAULT}
+ *
+ * @since 7.4.0
+ */
+ public boolean isRunHeavyweightSkippableTasks() {
+ return myRunHeavyweightSkippableTasks;
+ }
+
+ /**
+ * Should we run the tasks marked with {@link ca.uhn.fhir.jpa.migrate.tasks.api.TaskFlagEnum#HEAVYWEIGHT_SKIP_BY_DEFAULT}
+ *
+ * @since 7.4.0
+ */
+ public void setRunHeavyweightSkippableTasks(boolean theRunHeavyweightSkippableTasks) {
+ myRunHeavyweightSkippableTasks = theRunHeavyweightSkippableTasks;
+ }
+
public boolean isNoColumnShrink() {
return myNoColumnShrink;
}
@@ -131,14 +151,27 @@ public class HapiMigrator {
try (DriverTypeEnum.ConnectionProperties connectionProperties =
getDriverType().newConnectionProperties(getDataSource())) {
- newTaskList.forEach(next -> {
+ if (!isRunHeavyweightSkippableTasks()) {
+ newTaskList.removeIf(BaseTask::isHeavyweightSkippableTask);
+ }
+
+ boolean initializedSchema = false;
+ for (BaseTask next : newTaskList) {
+ if (initializedSchema && !next.hasFlag(TaskFlagEnum.RUN_DURING_SCHEMA_INITIALIZATION)) {
+ ourLog.info("Skipping task {} because schema is being initialized", next.getMigrationVersion());
+ recordTaskAsCompletedIfNotDryRun(next, 0L, true);
+ continue;
+ }
+
next.setDriverType(getDriverType());
next.setDryRun(isDryRun());
next.setNoColumnShrink(isNoColumnShrink());
next.setConnectionProperties(connectionProperties);
executeTask(next, retval);
- });
+
+ initializedSchema |= next.initializedSchema();
+ }
}
} catch (Exception e) {
ourLog.error("Migration failed", e);
@@ -167,13 +200,13 @@ public class HapiMigrator {
}
preExecute(theTask);
theTask.execute();
- postExecute(theTask, sw, true);
+ recordTaskAsCompletedIfNotDryRun(theTask, sw.getMillis(), true);
theMigrationResult.changes += theTask.getChangesCount();
theMigrationResult.executedStatements.addAll(theTask.getExecutedStatements());
theMigrationResult.succeededTasks.add(theTask);
} catch (SQLException | HapiMigrationException e) {
theMigrationResult.failedTasks.add(theTask);
- postExecute(theTask, sw, false);
+ recordTaskAsCompletedIfNotDryRun(theTask, sw.getMillis(), false);
String description = theTask.getDescription();
if (isBlank(description)) {
description = theTask.getClass().getSimpleName();
@@ -187,9 +220,9 @@ public class HapiMigrator {
myCallbacks.forEach(action -> action.preExecution(theTask));
}
- private void postExecute(BaseTask theNext, StopWatch theStopWatch, boolean theSuccess) {
+ private void recordTaskAsCompletedIfNotDryRun(BaseTask theNext, long theExecutionMillis, boolean theSuccess) {
if (!theNext.isDryRun()) {
- myHapiMigrationStorageSvc.saveTask(theNext, Math.toIntExact(theStopWatch.getMillis()), theSuccess);
+ myHapiMigrationStorageSvc.saveTask(theNext, Math.toIntExact(theExecutionMillis), theSuccess);
}
}
@@ -211,7 +244,7 @@ public class HapiMigrator {
}
public void setCallbacks(@Nonnull List theCallbacks) {
- Validate.notNull(theCallbacks);
+ Validate.notNull(theCallbacks, "theCallbacks must not be null");
myCallbacks = theCallbacks;
}
diff --git a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/MigrationTaskList.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/MigrationTaskList.java
index 668b51095c9..17a56f5a48b 100644
--- a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/MigrationTaskList.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/MigrationTaskList.java
@@ -29,6 +29,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
+import java.util.function.Predicate;
import java.util.stream.Collectors;
public class MigrationTaskList implements Iterable {
@@ -95,4 +96,12 @@ public class MigrationTaskList implements Iterable {
.reduce((first, second) -> second)
.orElse(null);
}
+
+ public void removeIf(Predicate theFilter) {
+ myTasks.removeIf(theFilter);
+ }
+
+ public BaseTask[] toTaskArray() {
+ return myTasks.toArray(new BaseTask[0]);
+ }
}
diff --git a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/MigrationTaskSkipper.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/MigrationTaskSkipper.java
index 0e74e504380..6de5b05fe3d 100644
--- a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/MigrationTaskSkipper.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/MigrationTaskSkipper.java
@@ -20,6 +20,7 @@
package ca.uhn.fhir.jpa.migrate;
import ca.uhn.fhir.jpa.migrate.taskdef.BaseTask;
+import ca.uhn.fhir.jpa.migrate.tasks.api.TaskFlagEnum;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,7 +50,7 @@ public class MigrationTaskSkipper {
for (BaseTask task : theTasks) {
if (skippedVersionSet.contains(task.getMigrationVersion())) {
ourLog.info("Will skip {}: {}", task.getMigrationVersion(), task.getDescription());
- task.setDoNothing(true);
+ task.addFlag(TaskFlagEnum.DO_NOTHING);
}
}
}
diff --git a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddColumnTask.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddColumnTask.java
index d1e6ed52064..933b81d3e8a 100644
--- a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddColumnTask.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddColumnTask.java
@@ -35,12 +35,6 @@ public class AddColumnTask extends BaseTableColumnTypeTask {
return new AddColumnTask(null, null, ColumnNameCase.ALL_LOWER, theColumnDriverMappingOverrides);
}
- public AddColumnTask() {
- this(null, null);
- setDryRun(true);
- myCheckForExistingTables = false;
- }
-
public AddColumnTask(String theProductVersion, String theSchemaVersion) {
super(theProductVersion, theSchemaVersion);
}
@@ -84,6 +78,7 @@ public class AddColumnTask extends BaseTableColumnTypeTask {
break;
case DERBY_EMBEDDED:
case POSTGRES_9_4:
+ case COCKROACHDB_21_1:
sql = "alter table " + getTableName() + " add column " + getColumnName() + " " + typeStatement;
break;
case MSSQL_2012:
diff --git a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddTableByColumnTask.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddTableByColumnTask.java
index abf38c1672a..969a05b21c0 100644
--- a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddTableByColumnTask.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddTableByColumnTask.java
@@ -56,7 +56,7 @@ public class AddTableByColumnTask extends BaseTableTask {
this(theProductVersion, theSchemaVersion, null);
}
- private AddTableByColumnTask(
+ public AddTableByColumnTask(
String theProductVersion, String theSchemaVersion, Comparator theColumnSortingRules) {
super(theProductVersion, theSchemaVersion);
myColumnSortingRules = theColumnSortingRules;
diff --git a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ArbitrarySqlTask.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ArbitrarySqlTask.java
index e3b9459fe06..41dedf315a7 100644
--- a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ArbitrarySqlTask.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ArbitrarySqlTask.java
@@ -46,6 +46,9 @@ public class ArbitrarySqlTask extends BaseTask {
private String myExecuteOnlyIfTableExists;
private List myConditionalOnExistenceOf = new ArrayList<>();
+ /**
+ * Constructor
+ */
public ArbitrarySqlTask(VersionEnum theRelease, String theVersion, String theTableName, String theDescription) {
super(theRelease.toString(), theVersion);
myTableName = theTableName;
diff --git a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java
index 50b7859a0a9..f652fa0a938 100644
--- a/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java
@@ -22,10 +22,14 @@ package ca.uhn.fhir.jpa.migrate.taskdef;
import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.jpa.migrate.DriverTypeEnum;
import ca.uhn.fhir.jpa.migrate.HapiMigrationException;
+import ca.uhn.fhir.jpa.migrate.tasks.api.TaskFlagEnum;
import ca.uhn.fhir.system.HapiSystemProperties;
+import jakarta.annotation.Nonnull;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
import org.flywaydb.core.api.MigrationVersion;
import org.intellij.lang.annotations.Language;
import org.slf4j.Logger;
@@ -38,6 +42,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -51,11 +56,42 @@ public abstract class BaseTask {
private static final Pattern versionPattern = Pattern.compile(MIGRATION_VERSION_PATTERN);
private final String myProductVersion;
private final String mySchemaVersion;
+ private final List myPreconditions = new ArrayList<>();
+ private final EnumSet myFlags = EnumSet.noneOf(TaskFlagEnum.class);
+ private final List myExecutedStatements = new ArrayList<>();
+ /**
+ * Whether to check for existing tables
+ * before generating SQL
+ */
+ protected boolean myCheckForExistingTables = true;
+ /**
+ * Whether to generate the SQL in a 'readable format'
+ */
+ protected boolean myPrettyPrint = false;
+
private DriverTypeEnum.ConnectionProperties myConnectionProperties;
private DriverTypeEnum myDriverType;
private String myDescription;
private Integer myChangesCount = 0;
private boolean myDryRun;
+ private boolean myTransactional = true;
+ private Set myOnlyAppliesToPlatforms = new HashSet<>();
+ private boolean myNoColumnShrink;
+
+ protected BaseTask(String theProductVersion, String theSchemaVersion) {
+ myProductVersion = theProductVersion;
+ mySchemaVersion = theSchemaVersion;
+ }
+
+ /**
+ * Adds a flag if it's not already present, otherwise this call is ignored.
+ *
+ * @param theFlag The flag, must not be null
+ */
+ public BaseTask addFlag(@Nonnull TaskFlagEnum theFlag) {
+ myFlags.add(theFlag);
+ return this;
+ }
/**
* Some migrations can not be run in a transaction.
@@ -65,48 +101,12 @@ public abstract class BaseTask {
myTransactional = theTransactional;
}
- private boolean myTransactional = true;
- private boolean myDoNothing;
- private List myExecutedStatements = new ArrayList<>();
- private Set myOnlyAppliesToPlatforms = new HashSet<>();
- private boolean myNoColumnShrink;
- private boolean myFailureAllowed;
- private boolean myRunDuringSchemaInitialization;
- /**
- * Whether or not to check for existing tables
- * before generating SQL
- */
- protected boolean myCheckForExistingTables = true;
-
- /**
- * Whether or not to generate the SQL in a 'readable format'
- */
- protected boolean myPrettyPrint = false;
-
- protected BaseTask(String theProductVersion, String theSchemaVersion) {
- myProductVersion = theProductVersion;
- mySchemaVersion = theSchemaVersion;
- }
-
- public boolean isRunDuringSchemaInitialization() {
- return myRunDuringSchemaInitialization;
- }
-
public void setPrettyPrint(boolean thePrettyPrint) {
myPrettyPrint = thePrettyPrint;
}
- /**
- * Should this task run even if we're doing the very first initialization of an empty schema. By
- * default we skip most tasks during that pass, since they just take up time and the
- * schema should be fully initialized by the {@link InitializeSchemaTask}
- */
- public void setRunDuringSchemaInitialization(boolean theRunDuringSchemaInitialization) {
- myRunDuringSchemaInitialization = theRunDuringSchemaInitialization;
- }
-
public void setOnlyAppliesToPlatforms(Set theOnlyAppliesToPlatforms) {
- Validate.notNull(theOnlyAppliesToPlatforms);
+ Validate.notNull(theOnlyAppliesToPlatforms, "theOnlyAppliesToPlatforms must not be null");
myOnlyAppliesToPlatforms = theOnlyAppliesToPlatforms;
}
@@ -188,7 +188,7 @@ public abstract class BaseTask {
private Integer doExecuteSqlList(List theSqlStatements) {
int changesCount = 0;
- for (String nextSql : theSqlStatements) {
+ for (@Language("SQL") String nextSql : theSqlStatements) {
changesCount += doExecuteSql(nextSql);
}
@@ -206,7 +206,7 @@ public abstract class BaseTask {
}
return changesCount;
} catch (DataAccessException e) {
- if (myFailureAllowed) {
+ if (myFlags.contains(TaskFlagEnum.FAILURE_ALLOWED)) {
ourLog.info("Task {} did not exit successfully, but task is allowed to fail", getMigrationVersion());
ourLog.debug("Error was: {}", e.getMessage(), e);
return 0;
@@ -219,7 +219,7 @@ public abstract class BaseTask {
protected void captureExecutedStatement(
String theTableName, @Language("SQL") String theSql, Object... theArguments) {
- myExecutedStatements.add(new ExecutedStatement(theTableName, theSql, theArguments));
+ myExecutedStatements.add(new ExecutedStatement(mySchemaVersion, theTableName, theSql, theArguments));
}
public DriverTypeEnum.ConnectionProperties getConnectionProperties() {
@@ -250,10 +250,8 @@ public abstract class BaseTask {
return getConnectionProperties().newJdbcTemplate();
}
- private final List myPreconditions = new ArrayList<>();
-
public void execute() throws SQLException {
- if (myDoNothing) {
+ if (myFlags.contains(TaskFlagEnum.DO_NOTHING)) {
ourLog.info("Skipping stubbed task: {}", getDescription());
return;
}
@@ -278,14 +276,6 @@ public abstract class BaseTask {
protected abstract void doExecute() throws SQLException;
- protected boolean isFailureAllowed() {
- return myFailureAllowed;
- }
-
- public void setFailureAllowed(boolean theFailureAllowed) {
- myFailureAllowed = theFailureAllowed;
- }
-
public String getMigrationVersion() {
String releasePart = myProductVersion;
if (releasePart.startsWith("V")) {
@@ -296,6 +286,7 @@ public abstract class BaseTask {
return migrationVersion.getVersion();
}
+ @SuppressWarnings("StringConcatenationArgumentToLogCall")
protected void logInfo(Logger theLog, String theFormattedMessage, Object... theArguments) {
theLog.info(getMigrationVersion() + ": " + theFormattedMessage, theArguments);
}
@@ -308,23 +299,6 @@ public abstract class BaseTask {
}
}
- public void doNothing() {
- setDoNothing(true);
- }
-
- public void failureAllowed() {
- setFailureAllowed(true);
- }
-
- public boolean isDoNothing() {
- return myDoNothing;
- }
-
- public BaseTask setDoNothing(boolean theDoNothing) {
- myDoNothing = theDoNothing;
- return this;
- }
-
public void addPrecondition(ExecuteTaskPrecondition thePrecondition) {
myPreconditions.add(thePrecondition);
}
@@ -343,7 +317,6 @@ public abstract class BaseTask {
if (theObject == null || getClass().equals(theObject.getClass()) == false) {
return false;
}
- @SuppressWarnings("unchecked")
BaseTask otherObject = (BaseTask) theObject;
EqualsBuilder b = new EqualsBuilder();
@@ -357,17 +330,35 @@ public abstract class BaseTask {
return false;
}
+ public boolean isDoNothing() {
+ return myFlags.contains(TaskFlagEnum.DO_NOTHING);
+ }
+
+ public boolean isHeavyweightSkippableTask() {
+ return myFlags.contains(TaskFlagEnum.HEAVYWEIGHT_SKIP_BY_DEFAULT);
+ }
+
+ public boolean hasFlag(TaskFlagEnum theFlag) {
+ return myFlags.contains(theFlag);
+ }
+
public static class ExecutedStatement {
private final String mySql;
private final List