discourse/db/migrate/20220220234155_conform_bounce_error_code.rb
Loïc Guitaut 25138db433 DEV: Promote historic post_deploy migrations
This commit promotes all post_deploy migrations which existed in
Discourse v3.0.0 (timestamp <= 20221212234948)
2023-07-26 10:36:37 +02:00

20 lines
442 B
Ruby

# frozen_string_literal: true
#
class ConformBounceErrorCode < ActiveRecord::Migration[6.1]
def up
DB.exec(<<~SQL, regexp: '\d\.\d\.\d+|\d{3}')
UPDATE email_logs
SET bounce_error_code = (
SELECT array_to_string(
regexp_matches(bounce_error_code, :regexp),
''
)
) WHERE bounce_error_code IS NOT NULL;
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end