mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-24 02:51:43 +01:00
4a87f697a9
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.
18 lines
400 B
Ruby
18 lines
400 B
Ruby
# 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
|