refactor: replace focusedIndex with activeChildId
- Replace focusedIndex integer with activeChildId string in messages schema - Add migration to convert existing data and drop focused_index column - Add hooks for providers.updatedAt and messageParts.lastUpdatedAt - Add file size column to files table - Update message navigation to use child ID-based lookup - Simplify delete logic by removing focusedIndex math - Fix file delete endpoint filename ([id[ -> [id])
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
ALTER TABLE "files" ADD COLUMN "size" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "messages" ADD COLUMN "active_child_id" text;--> statement-breakpoint
|
||||
UPDATE "messages" m
|
||||
SET "active_child_id" = (
|
||||
SELECT child."id"
|
||||
FROM "messages" child
|
||||
WHERE child."parent_message_id" = m."id"
|
||||
ORDER BY child."created_at" ASC
|
||||
OFFSET (m."focused_index" - 1)
|
||||
LIMIT 1
|
||||
)
|
||||
WHERE m."focused_index" IS NOT NULL AND m."focused_index" > 0;--> statement-breakpoint
|
||||
ALTER TABLE "messages" DROP COLUMN "focused_index";
|
||||
Reference in New Issue
Block a user