FIX: Set chat_allowed_groups based on chat_enabled setting (#19146)
Sets the chat_allowed_groups to staff (the old default) in the database for
people who already have chat enabled if they did not already change it.
The assumption is that most people who this applies to will be
upgrading from a version that has neither of these two PRs (
the other PR being #19116) to a version that has both of these PRs.
So, for existing site with chat enabled who haven’t set groups, we
want to persist the value which is more likely to match what that are
upgrading from (staff).
People who don’t yet have chat enabled should get the new value (TL1
and staff) when they do enable it.
Follow up to 05b740036e
This commit is contained in:
parent
5552e257d8
commit
0c1e5a76ee
|
@ -0,0 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SaveChatAllowedGroupsSiteSetting < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
chat_enabled = DB.query_single("SELECT value FROM site_settings WHERE name = 'chat_enabled' AND value = 't'")
|
||||
return if chat_enabled.blank?
|
||||
|
||||
chat_allowed_groups = DB.query_single("SELECT value FROM site_settings WHERE name = 'chat_allowed_groups'")
|
||||
return if chat_allowed_groups.blank?
|
||||
|
||||
# The original default was auto group ID 3 (staff) so we are
|
||||
# using that here.
|
||||
DB.exec(<<~SQL)
|
||||
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
|
||||
VALUES ('chat_allowed_groups', 20, '3', now(), now())
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue