Skip to content

A platform for community discussion. Free, open, simple.

DEV: Remove user options that are now not used (#42841)

Natalie Tay2ad5c29a2cda
diff --git a/app/models/user_option.rb b/app/models/user_option.rb
index b5174056174..131a17c78c0 100644
--- a/app/models/user_option.rb
+++ b/app/models/user_option.rb
@@ -23,6 +23,13 @@ class UserOption < ActiveRecord::Base
"chat_send_shortcut", # TODO(2027-01): replaced by send_shortcut; drop the column in a follow-up PR once this has shipped
"enable_defer", # TODO(2027-02): the preference was removed; drop the column in a follow-up PR once this has shipped
]
+ # TODO: remove after 20260824051214_drop_ai_search_discovery_preferences_from_user_options has been promoted
+ self.ignored_columns += %w[
+ ai_search_discoveries_mode
+ ai_search_discoveries_show_summary
+ ai_search_discoveries_summary_detail
+ ai_search_discoveries_related_count
+ ]
self.primary_key = :user_id
belongs_to :user
@@ -277,10 +284,6 @@ end
# Table name: user_options
#
# ai_search_discoveries :boolean default(TRUE), not null
-# ai_search_discoveries_mode :integer default(1), not null
-# ai_search_discoveries_related_count :integer default(2), not null
-# ai_search_discoveries_show_summary :boolean default(TRUE), not null
-# ai_search_discoveries_summary_detail :integer default(1), not null
# allow_private_messages :boolean default(TRUE), not null
# auto_image_caption :boolean default(FALSE), not null
# auto_track_topics_after_msecs :integer
diff --git a/db/structure.sql b/db/structure.sql
index c910b8086a0..5fa8b9bf490 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -11898,11 +11898,7 @@ CREATE TABLE public.user_options (
push_notification_level integer DEFAULT 1 NOT NULL,
automatically_translate boolean DEFAULT true NOT NULL,
understood_languages character varying[] DEFAULT '{}'::character varying[] NOT NULL,
- send_shortcut integer DEFAULT 0 NOT NULL,
- ai_search_discoveries_mode integer DEFAULT 1 NOT NULL,
- ai_search_discoveries_show_summary boolean DEFAULT true NOT NULL,
- ai_search_discoveries_summary_detail integer DEFAULT 1 NOT NULL,
- ai_search_discoveries_related_count integer DEFAULT 2 NOT NULL
+ send_shortcut integer DEFAULT 0 NOT NULL
);
@@ -23362,6 +23358,7 @@ SET search_path TO "$user", public;
INSERT INTO "schema_migrations" (version) VALUES
('20260824072257'),
+('20260824051214'),
('20260820171539'),
('20260820143851'),
('20260818143417'),
diff --git a/plugins/discourse-ai/db/migrate/20260814083721_add_ai_search_discovery_preferences_to_user_options.rb b/plugins/discourse-ai/db/migrate/20260814083721_add_ai_search_discovery_preferences_to_user_options.rb
index 2c022cda3ab..2ddf3af62a3 100644
--- a/plugins/discourse-ai/db/migrate/20260814083721_add_ai_search_discovery_preferences_to_user_options.rb
+++ b/plugins/discourse-ai/db/migrate/20260814083721_add_ai_search_discovery_preferences_to_user_options.rb
@@ -2,21 +2,5 @@
class AddAiSearchDiscoveryPreferencesToUserOptions < ActiveRecord::Migration[8.0]
def change
- add_column :user_options, :ai_search_discoveries_mode, :integer, default: 1, null: false
- add_column :user_options,
- :ai_search_discoveries_show_summary,
- :boolean,
- default: true,
- null: false
- add_column :user_options,
- :ai_search_discoveries_summary_detail,
- :integer,
- default: 1,
- null: false
- add_column :user_options,
- :ai_search_discoveries_related_count,
- :integer,
- default: 2,
- null: false
end
end
diff --git a/plugins/discourse-ai/db/post_migrate/20260824051214_drop_ai_search_discovery_preferences_from_user_options.rb b/plugins/discourse-ai/db/post_migrate/20260824051214_drop_ai_search_discovery_preferences_from_user_options.rb
new file mode 100644
index 00000000000..8f9811daec3
--- /dev/null
+++ b/plugins/discourse-ai/db/post_migrate/20260824051214_drop_ai_search_discovery_preferences_from_user_options.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class DropAiSearchDiscoveryPreferencesFromUserOptions < ActiveRecord::Migration[8.0]
+ DROPPED_COLUMNS = {
+ user_options: %i[
+ ai_search_discoveries_mode
+ ai_search_discoveries_show_summary
+ ai_search_discoveries_summary_detail
+ ai_search_discoveries_related_count
+ ],
+ }
+
+ def up
+ DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end