Files
gramsrv/deploy/migrations/0223_botfather_delete_command.down.sql
opencode 123ddd8209 fix(migrations): renumber the botfather migration to 0223
Upstream filled 0219 with star_gift_deterministic_attributes while these
commits were missing from the branch, so the botfather migration collided
on version 219 and both golang-migrate and the embedded-migration checks
rejected the series. Move it to 0223, the next free slot after 0222, and
advance the timestamp predecessor pin that tracks the head of the
numbered chain.
2026-10-12 18:15:26 +03:00

27 lines
1.1 KiB
SQL

UPDATE public.bots
SET commands = (
SELECT COALESCE(jsonb_agg(
CASE item.command->>'command'
WHEN 'mybots' THEN jsonb_set(item.command, '{description}', '"list your bots"'::jsonb)
WHEN 'token' THEN jsonb_set(item.command, '{description}', '"show a bot''s token"'::jsonb)
WHEN 'revoke' THEN jsonb_set(item.command, '{description}', '"revoke a bot''s token"'::jsonb)
ELSE item.command
END ORDER BY item.ordinal), '[]'::jsonb)
FROM jsonb_array_elements(commands) WITH ORDINALITY AS item(command, ordinal)
),
updated_at = now()
WHERE bot_user_id = 93372553;
UPDATE public.bots
SET commands = COALESCE((
SELECT jsonb_agg(command ORDER BY ordinal)
FROM jsonb_array_elements(commands) WITH ORDINALITY AS item(command, ordinal)
WHERE command->>'command' <> 'deletebot'
), '[]'::jsonb),
updated_at = now()
WHERE bot_user_id = 93372553;
UPDATE public.users
SET bot_info_version = bot_info_version + 1,
updated_at = now()
WHERE id = 93372553;