From 55a00b1de48f7c5f2d9049883bd459769b20fbe4 Mon Sep 17 00:00:00 2001 From: Trisha Anand Date: Mon, 24 Feb 2025 17:08:22 +0530 Subject: [PATCH] fix: drop the organization collection (ex workspace) before inserting the default organization (tenant) (#39416) ## Description This is for old deployments which existed before the ACL changes came in migrating organization to workspace. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="" ### :mag: Cypress test results > [!CAUTION] > If you modify the content in this section, you are likely to disrupt the CI result for your PR. ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **Chores** - Enhanced the data migration process to automatically clear outdated organization records before migrating tenant data, reducing potential conflicts and ensuring a smoother update process. --- .../db/ce/Migration065_CopyTenantIdToOrganizationId.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration065_CopyTenantIdToOrganizationId.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration065_CopyTenantIdToOrganizationId.java index 77aee87773..787dd29a63 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration065_CopyTenantIdToOrganizationId.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration065_CopyTenantIdToOrganizationId.java @@ -64,6 +64,13 @@ public class Migration065_CopyTenantIdToOrganizationId { } private void migrateTenantCollection() { + + // Drop the organization collection if it exists + if (mongoTemplate.collectionExists(Organization.class)) { + log.info("Dropping existing organization collection"); + mongoTemplate.dropCollection(Organization.class); + } + try { // Get the single tenant document Document tenant = mongoTemplate.findOne(new Query(), Document.class, "tenant");