From 64d2a6eba01130c7732b068c69873c0773c396b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Fourn=C3=A8s?= Date: Tue, 20 Feb 2024 08:48:52 +0000 Subject: [PATCH] fix invalid domain block severities This commit fixes any invalid domain block severities by setting them to 2 if they are bigger than 2 or 0 if they are smaller than 0. This ensures that the domain block severities are always within the valid range of 0 to 2. --- ...82519_fix_invalid_domain_block_severities.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 db/migrate/20240220082519_fix_invalid_domain_block_severities.rb diff --git a/db/migrate/20240220082519_fix_invalid_domain_block_severities.rb b/db/migrate/20240220082519_fix_invalid_domain_block_severities.rb new file mode 100644 index 00000000000..ff0caac2ceb --- /dev/null +++ b/db/migrate/20240220082519_fix_invalid_domain_block_severities.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class FixInvalidDomainBlockSeverities < ActiveRecord::Migration[7.1] + disable_ddl_transaction! + + def up + safety_assured do + execute <<~SQL.squish + UPDATE domain_blocks + SET severity = CASE WHEN severity > 2 THEN 2 WHEN severity < 0 THEN 0 END + WHERE severity > 2 OR severity < 0 RETURNING id; + SQL + end + end + + def down; end +end