From 73c80321785ded40e7652042b5085c96c495c3a1 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 27 May 2022 20:05:22 +0200 Subject: [PATCH] Remove unused `filtered_languages` column (#18533) * Remove unused `filtered_languages` column Fixes #18522 * Fix tests --- app/models/user.rb | 2 +- ...0527114923_remove_filtered_languages_from_users.rb | 11 +++++++++++ db/schema.rb | 3 +-- .../settings/preferences/other_controller_spec.rb | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 db/post_migrate/20220527114923_remove_filtered_languages_from_users.rb diff --git a/app/models/user.rb b/app/models/user.rb index ab2e391e9b..23febb6fee 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -26,7 +26,6 @@ # otp_required_for_login :boolean default(FALSE), not null # last_emailed_at :datetime # otp_backup_codes :string is an Array -# filtered_languages :string default([]), not null, is an Array # account_id :bigint(8) not null # disabled :boolean default(FALSE), not null # moderator :boolean default(FALSE), not null @@ -48,6 +47,7 @@ class User < ApplicationRecord current_sign_in_ip last_sign_in_ip skip_sign_in_token + filtered_languages ) include Settings::Extend diff --git a/db/post_migrate/20220527114923_remove_filtered_languages_from_users.rb b/db/post_migrate/20220527114923_remove_filtered_languages_from_users.rb new file mode 100644 index 0000000000..bd3664c727 --- /dev/null +++ b/db/post_migrate/20220527114923_remove_filtered_languages_from_users.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class RemoveFilteredLanguagesFromUsers < ActiveRecord::Migration[6.1] + disable_ddl_transaction! + + def change + safety_assured do + remove_column :users, :filtered_languages, :string, array: true, default: [], null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 726989beff..081955660d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_04_29_101850) do +ActiveRecord::Schema.define(version: 2022_05_27_114923) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -983,7 +983,6 @@ ActiveRecord::Schema.define(version: 2022_04_29_101850) do t.boolean "otp_required_for_login", default: false, null: false t.datetime "last_emailed_at" t.string "otp_backup_codes", array: true - t.string "filtered_languages", default: [], null: false, array: true t.bigint "account_id", null: false t.boolean "disabled", default: false, null: false t.boolean "moderator", default: false, null: false diff --git a/spec/controllers/settings/preferences/other_controller_spec.rb b/spec/controllers/settings/preferences/other_controller_spec.rb index 1b556ac7f7..960378a018 100644 --- a/spec/controllers/settings/preferences/other_controller_spec.rb +++ b/spec/controllers/settings/preferences/other_controller_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Settings::Preferences::OtherController do render_views - let(:user) { Fabricate(:user, filtered_languages: []) } + let(:user) { Fabricate(:user, chosen_languages: []) } before do sign_in user, scope: :user