Skip to content

Commit

Permalink
added client side migration
Browse files Browse the repository at this point in the history
  • Loading branch information
sondermanish committed Jan 7, 2025
1 parent b526e61 commit 593cba7
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,35 @@ public Mono<ApplicationJson> migrateApplicationJsonToLatestSchema(
return Mono.empty();
}

return migrateServerSchema(applicationJson, baseApplicationId, refName);
return migrateClientSchema(appJson, baseApplicationId, refName)
.flatMap(clientJson -> migrateServerSchema(clientJson, baseApplicationId, refName));
})
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.INCOMPATIBLE_IMPORTED_JSON)));
}

private Mono<ApplicationJson> migrateClientSchema(
ApplicationJson applicationJson, String baseApplicationId, String branchName) {

Mono<ApplicationJson> migrateApplicationJsonMono = Mono.just(applicationJson);
if (jsonSchemaVersions.getClientVersion().equals(applicationJson.getClientSchemaVersion())) {
return migrateApplicationJsonMono;
}

// Run migration linearly
// Updating the schema version after each migration is not required as we are not exiting by breaking the switch
// cases, but this keeps the version number and the migration in sync
switch (applicationJson.getClientSchemaVersion()) {
case 0:
applicationJson.setClientSchemaVersion(1);
case 1:
applicationJson.setClientSchemaVersion(2);
default:
}

applicationJson.setClientSchemaVersion(jsonSchemaVersions.getClientVersion());
return migrateApplicationJsonMono;
}

/**
* This method may be moved to the publisher chain itself
*
Expand Down

0 comments on commit 593cba7

Please sign in to comment.