FIX: Account for empty string setting values when migrating category settings (#22979)

This migration that populates category setting data from custom fields did not account for the fact that custom fields that expect an integer can still be an empty string. An empty string can't be inserted into the new integer type column.

If the setting is an empty string, cast it to NULL.
This commit is contained in:
Ted Johansson 2023-08-04 20:57:48 +08:00 committed by GitHub
parent b7e642d99d
commit 207d983809
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -10,15 +10,15 @@ class ChangeCategorySettingNumAutoBumpDailyDefault < ActiveRecord::Migration[7.0
category_id,
MAX(
CASE WHEN (name = 'require_topic_approval')
THEN value ELSE NULL END
THEN NULLIF(value, '') ELSE NULL END
)::boolean AS require_topic_approval,
MAX(
CASE WHEN (name = 'require_reply_approval')
THEN value ELSE NULL END
THEN NULLIF(value, '') ELSE NULL END
)::boolean AS require_reply_approval,
MAX(
CASE WHEN (name = 'num_auto_bump_daily')
THEN value ELSE NULL END
THEN NULLIF(value, '') ELSE NULL END
)::integer AS num_auto_bump_daily,
NOW() AS created_at,
NOW() AS updated_at