mirror of
https://ghfast.top/https://github.com/discourse/discourse-translator.git
synced 2026-07-15 11:36:26 +08:00
In https://github.com/discourse/discourse-translator/pull/203 we introduced a bug for the amazon provider, which was fixed in https://github.com/discourse/discourse-translator/pull/297. This commit is a migration to purge the incorrect translations that have been stored. The translation will look like the following as the full response is saved instead of the specific attribute. ``` {translated_text: ... ```
22 lines
566 B
Ruby
22 lines
566 B
Ruby
# 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
|