From 70ee47f9c37c8fe51a20063abf8de464bdacb59c Mon Sep 17 00:00:00 2001 From: Nat Date: Thu, 22 May 2025 15:17:34 +0800 Subject: [PATCH] DEV: Clean up amazon translations due to parsing error --- ...50522045138_cleanup_amazon_translations.rb | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 db/migrate/20250522045138_cleanup_amazon_translations.rb diff --git a/db/migrate/20250522045138_cleanup_amazon_translations.rb b/db/migrate/20250522045138_cleanup_amazon_translations.rb new file mode 100644 index 00000000..95362ce0 --- /dev/null +++ b/db/migrate/20250522045138_cleanup_amazon_translations.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class CleanupAmazonTranslations < ActiveRecord::Migration[7.2] + def up + provider = + DB.query_single("SELECT value FROM site_settings WHERE name = 'translator_provider'").first + if provider == "Amazon" + execute <<~SQL + DELETE FROM discourse_translator_post_translations + WHERE translation LIKE '{:translated_text%' + SQL + + execute <<~SQL + DELETE FROM discourse_translator_topic_translations + WHERE translation LIKE '{:translated_text%' + SQL + end + end + + def down + end +end