Files
prod/migrations/20261019120000_merge_text_screen_modes.sql
T
2026-10-19 02:34:30 +07:00

34 lines
982 B
SQL

-- +goose Up
UPDATE game_screen_plans
SET steps = (
SELECT jsonb_agg(
CASE WHEN step->>'mode' IN ('3', '5') THEN
step || jsonb_build_object(
'mode', 8,
'text', CASE step->>'mode'
WHEN '3' THEN 'Успехов'
ELSE 'Спасибо за игру!'
END
)
ELSE step END
ORDER BY position
)
FROM jsonb_array_elements(steps) WITH ORDINALITY AS items(step, position)
), updated_at = NOW()
WHERE EXISTS (
SELECT 1
FROM jsonb_array_elements(steps) AS step
WHERE step->>'mode' IN ('3', '5')
);
UPDATE screen_sessions
SET text = CASE mode WHEN 3 THEN 'Успехов' ELSE 'Спасибо за игру!' END,
mode = 8,
command = 0,
state_version = state_version + 1,
updated_at = NOW()
WHERE mode IN (3, 5);
-- +goose Down
-- Text screens remain valid in the previous version; original modes cannot be recovered.