diff --git a/db/migrate/20241217041352_fix_old_audio_alert_data.rb b/db/migrate/20241217041352_fix_old_audio_alert_data.rb new file mode 100644 index 000000000..7a069d24f --- /dev/null +++ b/db/migrate/20241217041352_fix_old_audio_alert_data.rb @@ -0,0 +1,18 @@ +class FixOldAudioAlertData < ActiveRecord::Migration[7.0] + def change + # rubocop:disable Rails/SkipsModelValidations + + # Update users with audio alerts enabled to 'mine' + User.where( + "users.ui_settings #>> '{enable_audio_alerts}' = ?", 'true' + ).update_all( + "ui_settings = jsonb_set(ui_settings, '{enable_audio_alerts}', '\"mine\"')" + ) + + # Update users with audio alerts enabled to 'none' + User + .where("users.ui_settings #>> '{enable_audio_alerts}' = ?", 'true') + .update_all("ui_settings = jsonb_set(ui_settings, '{enable_audio_alerts}', '\"mine\"')") + # rubocop:enable Rails/SkipsModelValidations + end +end diff --git a/db/schema.rb b/db/schema.rb index abb14d1e9..63c889e3b 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[7.0].define(version: 2024_09_23_215335) do +ActiveRecord::Schema[7.0].define(version: 2024_12_17_041352) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "pg_trgm"