From 8630bc145e9ba154b287576ee7a33b6f9bb19ffe Mon Sep 17 00:00:00 2001 From: Natalie Tay Date: Thu, 17 Jul 2025 17:43:05 +0800 Subject: [PATCH] DEV: Set a min and max for translations backfill (#1508) Since we use the value for days.ago and are seeing PG::DatetimeFieldOverflow: ERROR: timestamp out of range: "5473790-07-13 08:43:28.497823 BC, set limits to the site setting. --- config/settings.yml | 2 ++ ...075002_set_translation_backfill_max_age.rb | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 db/migrate/20250717075002_set_translation_backfill_max_age.rb diff --git a/config/settings.yml b/config/settings.yml index 117b4115..80348b31 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -527,6 +527,8 @@ discourse_ai: area: "ai-features/translation" ai_translation_backfill_max_age_days: default: 5 + min: 0 + max: 20000 client: false area: "ai-features/translation" ai_translation_verbose_logs: diff --git a/db/migrate/20250717075002_set_translation_backfill_max_age.rb b/db/migrate/20250717075002_set_translation_backfill_max_age.rb new file mode 100644 index 00000000..3795cb9f --- /dev/null +++ b/db/migrate/20250717075002_set_translation_backfill_max_age.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true +class SetTranslationBackfillMaxAge < ActiveRecord::Migration[7.2] + def up + execute <<~SQL + UPDATE site_settings + SET value = '20000' + WHERE name = 'ai_translation_backfill_max_age_days' + AND value::integer > 20000; + SQL + + execute <<~SQL + UPDATE site_settings + SET value = '0' + WHERE name = 'ai_translation_backfill_max_age_days' + AND value::integer < 0; + SQL + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end