WebHooker/server/lib/web
RhenCloud 1a0500b812
fix: prevent data loss in routes, fragments, and group operations
Found and fixed multiple critical bugs with similar patterns:

1. routeStatements() used DELETE FROM d1_routes before re-inserting
   - Could cause data loss if interrupted or if logic changes
   - Now uses DELETE with WHERE clause + INSERT...ON CONFLICT (upsert)

2. saveFragments() used DELETE FROM d1_fragments before re-inserting
   - Same pattern as routes, fixed with targeted deletes + upsert
   - Added loadFragments() call to determine what to delete

3. adminGroupRename() didn't update fragment groupId
   - When renaming a group, fragments were left pointing to old groupId
   - Now updates fragments alongside routes, secrets, and invites

All changes follow the same safe pattern:
- Load existing data to identify what needs deletion
- Delete only removed items with WHERE clauses
- Use INSERT...ON CONFLICT DO UPDATE for upserts
- Never use bare DELETE FROM table

Testing: All 339 tests pass.
2026-09-10 22:35:43 +08:00
..
actions.ts feat(groups): host-based forge sources with optional display name 2026-08-14 08:49:48 +08:00
admin.ts fix: prevent data loss in routes, fragments, and group operations 2026-09-10 22:35:43 +08:00
auth.ts feat(storage): migrate config, dedup and delivery state to D1 2026-08-17 15:01:20 +08:00
groups.ts feat(storage): migrate config, dedup and delivery state to D1 2026-08-17 15:01:20 +08:00
invites.ts feat(storage): migrate config, dedup and delivery state to D1 2026-08-17 15:01:20 +08:00
oauth.ts feat(feishu): add Feishu inbound webhook, /gh commands and card actions 2026-08-27 00:07:05 +08:00
richheader.ts feat: migrate to Nuxt 4 (Nitro) and Tailwind CSS v3 2026-08-13 17:43:33 +08:00
session.ts feat(ui): update ui style 2026-08-16 22:46:07 +08:00
tenants.ts feat: migrate to Nuxt 4 (Nitro) and Tailwind CSS v3 2026-08-13 17:43:33 +08:00