diff --git a/app/client/packages/dsl/src/migrate/index.ts b/app/client/packages/dsl/src/migrate/index.ts index 738e4ac3e1c9..75ce6f7b6d5f 100644 --- a/app/client/packages/dsl/src/migrate/index.ts +++ b/app/client/packages/dsl/src/migrate/index.ts @@ -93,7 +93,7 @@ import { migrateCustomWidgetDynamicHeight } from "./migrations/088-migrate-custo import { migrateTableWidgetV2CurrentRowInValidationsBinding } from "./migrations/089-migrage-table-widget-v2-currentRow-binding"; import type { DSLWidget } from "./types"; -export const LATEST_DSL_VERSION = 90; +export const LATEST_DSL_VERSION = 91; export const calculateDynamicHeight = () => { const DEFAULT_GRID_ROW_HEIGHT = 10; @@ -613,6 +613,17 @@ const migrateVersionedDSL = async (currentDSL: DSLWidget, newPage = false) => { if (currentDSL.version === 89) { currentDSL = migrateTableWidgetV2CurrentRowInValidationsBinding(currentDSL); + currentDSL.version = 90; + } + + if (currentDSL.version === 90) { + /** + * This is just a version bump without any migration + * History: With this PR: https://github.com/appsmithorg/appsmith/pull/38391 + * we updated the `clientVersion` to 2. + * What we missed was that, the auto-commit does not handle clientVersion, which lead to this bug: https://github.com/appsmithorg/appsmith/issues/38511 + * We are bumping this version to make sure that the auto-commit will handle this version bump. + */ currentDSL.version = LATEST_DSL_VERSION; } diff --git a/app/client/packages/dsl/src/migrate/tests/DSLMigration.test.ts b/app/client/packages/dsl/src/migrate/tests/DSLMigration.test.ts index 76b4294ab87a..fd03b573d57e 100644 --- a/app/client/packages/dsl/src/migrate/tests/DSLMigration.test.ts +++ b/app/client/packages/dsl/src/migrate/tests/DSLMigration.test.ts @@ -930,6 +930,10 @@ const migrations: Migration[] = [ ], version: 89, }, + { + functionLookup: [], + version: 90, + }, ]; const mockFnObj: Record = {}; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java index c5cb0f0843fa..8d72075c6a41 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java @@ -68,11 +68,35 @@ public Mono 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 migrateClientSchema( + ApplicationJson applicationJson, String baseApplicationId, String branchName) { + + Mono 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 *