mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
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.
This commit is contained in:
parent
0b66433c08
commit
64d2a6eba0
1 changed files with 17 additions and 0 deletions
|
@ -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
|
Loading…
Reference in a new issue