FIX: Skip migrating null/blank custom field values in migrations

This commit is contained in:
David Taylor 2020-09-09 17:00:56 +01:00
parent 2bd2600476
commit 835b3580b7
No known key found for this signature in database
GPG Key ID: 46904C18B1D3F434
2 changed files with 3 additions and 0 deletions

View File

@ -15,6 +15,7 @@ class CreateDiscourseVotingVotes < ActiveRecord::Migration[6.0]
SELECT value::integer, user_id, 'false', created_at, updated_at
FROM user_custom_fields
WHERE name = 'votes'
AND value <> ''
ON CONFLICT(user_id, topic_id) DO NOTHING
SQL
@ -23,6 +24,7 @@ class CreateDiscourseVotingVotes < ActiveRecord::Migration[6.0]
SELECT value::integer, user_id, 'true', created_at, updated_at
FROM user_custom_fields
WHERE name = 'votes_archive'
AND value <> ''
ON CONFLICT(user_id, topic_id) DO NOTHING
SQL
end

View File

@ -14,6 +14,7 @@ class CreateDiscourseVotingTopicVoteCount < ActiveRecord::Migration[6.0]
SELECT topic_id::integer, value::integer, created_at, updated_at
FROM topic_custom_fields
WHERE name = 'vote_count'
AND value <> ''
SQL
end