@@ -459,37 +459,38 @@ protected void updateFhirSchema() {
459459 buildFhirDataSchemaModel (pdm );
460460 boolean isNewDb = updateSchema (pdm );
461461
462- // If the db is multi-tenant, we populate the resource types and parameter names in allocate-tenant.
463- // Otherwise, if its a new schema, populate the resource types and parameters names (codes) now
464- if (!MULTITENANT_FEATURE_ENABLED .contains (dbType ) && isNewDb ) {
465- populateResourceTypeAndParameterNameTableEntries (null );
466- }
467-
468- if (MULTITENANT_FEATURE_ENABLED .contains (dbType )) {
469- logger .info ("Refreshing tenant partitions" );
470- refreshTenants ();
471- }
472-
473- // backfill the resource_change_log table if needed
474- backfillResourceChangeLog ();
475-
476- // perform any updates we need related to the V0010 schema change (IS_DELETED flag)
477- applyDataMigrationForV0010 ();
478-
479- // V0014 IS_DELETED and LAST_UPDATED added to whole-system LOGICAL_RESOURCES
480- applyDataMigrationForV0014 ();
481-
482- // V0021 removes Abstract Type tables which are unused.
483- applyTableRemovalForV0021 ();
484-
485- // Apply privileges if asked
486- if (grantTo != null ) {
487- grantPrivilegesForFhirData ();
462+ if (this .exitStatus == EXIT_OK ) {
463+ // If the db is multi-tenant, we populate the resource types and parameter names in allocate-tenant.
464+ // Otherwise, if its a new schema, populate the resource types and parameters names (codes) now
465+ if (!MULTITENANT_FEATURE_ENABLED .contains (dbType ) && isNewDb ) {
466+ populateResourceTypeAndParameterNameTableEntries (null );
467+ }
468+
469+ if (MULTITENANT_FEATURE_ENABLED .contains (dbType )) {
470+ logger .info ("Refreshing tenant partitions" );
471+ refreshTenants ();
472+ }
473+
474+ // backfill the resource_change_log table if needed
475+ backfillResourceChangeLog ();
476+
477+ // perform any updates we need related to the V0010 schema change (IS_DELETED flag)
478+ applyDataMigrationForV0010 ();
479+
480+ // V0014 IS_DELETED and LAST_UPDATED added to whole-system LOGICAL_RESOURCES
481+ applyDataMigrationForV0014 ();
482+
483+ // V0021 removes Abstract Type tables which are unused.
484+ applyTableRemovalForV0021 ();
485+
486+ // Apply privileges if asked
487+ if (grantTo != null ) {
488+ grantPrivilegesForFhirData ();
489+ }
490+
491+ // Finally, update the whole schema version
492+ svm .updateSchemaVersion ();
488493 }
489-
490- // Finally, update the whole schema version
491- svm .updateSchemaVersion ();
492-
493494 }
494495 } finally {
495496 leaseManager .cancelLease ();
@@ -523,13 +524,15 @@ protected void updateOauthSchema() {
523524 buildOAuthSchemaModel (pdm );
524525 updateSchema (pdm );
525526
526- // Apply privileges if asked
527- if (grantTo != null ) {
528- grantPrivilegesForOAuth ();
527+ if (this .exitStatus == EXIT_OK ) {
528+ // Apply privileges if asked
529+ if (grantTo != null ) {
530+ grantPrivilegesForOAuth ();
531+ }
532+
533+ // Mark the schema as up-to-date
534+ svm .updateSchemaVersion ();
529535 }
530-
531- // Mark the schema as up-to-date
532- svm .updateSchemaVersion ();
533536 }
534537 } finally {
535538 leaseManager .cancelLease ();
@@ -562,14 +565,16 @@ protected void updateJavaBatchSchema() {
562565 PhysicalDataModel pdm = new PhysicalDataModel ();
563566 buildJavaBatchSchemaModel (pdm );
564567 updateSchema (pdm );
565-
566- // Apply privileges if asked
567- if (grantTo != null ) {
568- grantPrivilegesForBatch ();
568+
569+ if (this .exitStatus == EXIT_OK ) {
570+ // Apply privileges if asked
571+ if (grantTo != null ) {
572+ grantPrivilegesForBatch ();
573+ }
574+
575+ // Mark the schema as up-to-date
576+ svm .updateSchemaVersion ();
569577 }
570-
571- // Mark the schema as up-to-date
572- svm .updateSchemaVersion ();
573578 }
574579 } finally {
575580 leaseManager .cancelLease ();
0 commit comments