From 1528473dd0a7c5794c8baa193ad0275e57a2d8c2 Mon Sep 17 00:00:00 2001 From: Pranav Date: Mon, 20 Jan 2025 20:30:37 -0800 Subject: [PATCH] fix(ce): Check the edition before running the data migration (#10728) Fixes #10721 This PR addresses an issue where the data migration in the CE edition was failing due to missing models. The change ensures that the migration process runs only when the deployment is using the EE image. --- ...1033_convert_document_to_polymorphic_association.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/migrate/20250116061033_convert_document_to_polymorphic_association.rb b/db/migrate/20250116061033_convert_document_to_polymorphic_association.rb index d53e6853c..298053bde 100644 --- a/db/migrate/20250116061033_convert_document_to_polymorphic_association.rb +++ b/db/migrate/20250116061033_convert_document_to_polymorphic_association.rb @@ -3,10 +3,12 @@ class ConvertDocumentToPolymorphicAssociation < ActiveRecord::Migration[7.0] add_column :captain_assistant_responses, :documentable_type, :string # rubocop:disable Rails/SkipsModelValidations - Captain::AssistantResponse - .where - .not(document_id: nil) - .update_all(documentable_type: 'Captain::Document') + if ChatwootApp.enterprise? + Captain::AssistantResponse + .where + .not(document_id: nil) + .update_all(documentable_type: 'Captain::Document') + end # rubocop:enable Rails/SkipsModelValidations remove_index :captain_assistant_responses, :document_id if index_exists?( :captain_assistant_responses, :document_id