Skip to content

Commit

Permalink
fixed upgrade - don't create bonus key object if there is no bonus keys
Browse files Browse the repository at this point in the history
  • Loading branch information
bomzheg committed Dec 1, 2024
1 parent dd9499c commit 95de375
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,23 @@ def upgrade():
op.execute("""
WITH scn AS (
SELECT jsonb_insert(
l.scenario::JSONB,
'{conditions}',
jsonb_build_array(
jsonb_build_object(
'type', 'WIN_KEY',
'keys', l.scenario::JSONB->'keys'
),
jsonb_build_object(
'type', 'BONUS_KEY',
'keys', jsonb_extract_path(l.scenario::JSONB, 'bonus_keys')
)
)
) - 'keys' - 'bonus_keys' AS scenario,
l.id
l.scenario::JSONB,
'{conditions}',
jsonb_path_query_array(
jsonb_build_array(
jsonb_build_object(
'type', 'WIN_KEY',
'keys', l.scenario::JSONB->'keys'
),
jsonb_build_object(
'type', 'BONUS_KEY',
'keys', jsonb_extract_path(l.scenario::JSONB, 'bonus_keys')
)
),
'$[*] ? (@.keys != null && @.keys.size() > 0)'
)
) - 'keys' - 'bonus_keys' AS scenario,
l.id
FROM levels AS l
)
UPDATE levels lvl
Expand Down

0 comments on commit 95de375

Please sign in to comment.