-- 097_fix_migrated_purchase_menu_label_icon.sql -- -- Fixes the custom menu item created by migration 096: updates the label -- from hardcoded English "Purchase" to "充值/订阅", and sets the icon_svg -- to a credit-card SVG matching the sidebar CreditCardIcon. -- -- Idempotent: only modifies items where id = 'migrated_purchase_subscription'. DO $$ DECLARE v_raw text; v_items jsonb; v_idx int; v_icon text; v_elem jsonb; v_i int := 0; BEGIN SELECT value INTO v_raw FROM settings WHERE key = 'custom_menu_items'; IF COALESCE(v_raw, '') = '' OR v_raw = 'null' THEN RETURN; END IF; v_items := v_raw::jsonb; -- Find the index of the migrated item by iterating the array v_idx := NULL; FOR v_elem IN SELECT jsonb_array_elements(v_items) LOOP IF v_elem ->> 'id' = 'migrated_purchase_subscription' THEN v_idx := v_i; EXIT; END IF; v_i := v_i + 1; END LOOP; IF v_idx IS NULL THEN RETURN; -- item not found, nothing to fix END IF; -- Credit card SVG (Heroicons outline, matches CreditCardIcon in AppSidebar) v_icon := ''; -- Update label and icon_svg v_items := jsonb_set(v_items, ARRAY[v_idx::text, 'label'], '"充值/订阅"'::jsonb); v_items := jsonb_set(v_items, ARRAY[v_idx::text, 'icon_svg'], to_jsonb(v_icon)); UPDATE settings SET value = v_items::text WHERE key = 'custom_menu_items'; RAISE NOTICE '[migration-097] Fixed migrated_purchase_subscription: label=充值/订阅, icon=CreditCard SVG'; END $$;