feat(storage): persist the per-group route order

Routes used to load in id order, so the order saved from the console
was lost on the next read. Migration 0012 adds `d1_routes.position`:
saving writes each route's index within its own group (saving one group
never shifts another), and routes load by `group_id, position, id`.

A database without the column keeps working: only a "no such column" /
"has no column named" error falls back to the legacy statements, and
nothing is cached, so a later migration is picked up on the next call.
This commit is contained in:
翅膀 committed 2026-10-16 23:24:09 +08:00
1 parent 24d85fd2e6
commit d57e5c29c4
6 files changed
+181 -29

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
-- Persist the user-defined route order inside each group. Routes load ordered by
-- (group_id, position, id); rows written before this migration keep position 0
-- and therefore stay in id order until their group's routes are saved again.
ALTER TABLE d1_routes ADD COLUMN position INTEGER NOT NULL DEFAULT 0;
CREATE INDEX IF NOT EXISTS idx_d1_routes_group_position ON d1_routes (group_id, position);