From ca9549b04f5f1b16f6a09f7b4d86d86bac0ee078 Mon Sep 17 00:00:00 2001 From: Ted Johansson Date: Wed, 23 Oct 2024 13:02:02 +0800 Subject: [PATCH] DEV: Clear duplicate admin problem notices (#29358) In #29272 we added a backwards-compatible way to prevent duplicate problem check trackers. However, there was a mistake in the PR that would instead create duplicate admin notices. As a result, a number of admins now have multiple copies of the same admin notice in their dashboard. The root cause was fixed in #29329, preventing new duplicates. This PR is here to clean up notices that were already created. Admin notices are meant to be ephemeral. Instead of going through hoops to delete duplicates and update the remaining notices' unstructured field with the correct target, it is a lot less error-prone to delete all notices and let the problem check system re-create them. The real-time checks run every time the dashboard is loaded, so they will appear to never have been deleted. Any notices related to scheduled checks will be added back on the next run. This will happen within at most one hour, and isn't time sensitive. --- .../20241023041126_clear_duplicate_admin_notices.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/post_migrate/20241023041126_clear_duplicate_admin_notices.rb diff --git a/db/post_migrate/20241023041126_clear_duplicate_admin_notices.rb b/db/post_migrate/20241023041126_clear_duplicate_admin_notices.rb new file mode 100644 index 00000000000..670259d232f --- /dev/null +++ b/db/post_migrate/20241023041126_clear_duplicate_admin_notices.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true +class ClearDuplicateAdminNotices < ActiveRecord::Migration[7.1] + def up + problem_subject_id = 0 + + DB.exec(<<~SQL) + DELETE FROM admin_notices + WHERE subject = #{problem_subject_id} + SQL + end +end