mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
d5a1792f07
Needed by #23833 Adds a `chat_file_links` association table to track which files are associated with each chat. - `AppendChatFileIDs` query links a file to a chat with deduplication - `GetChatFileMetadataByIDs` query returns lightweight file metadata by IDs - Tool-created files (e.g. `propose_plan`) are linked to the chat after insert - User-uploaded files are linked to the chat when the referencing message is sent - Single-chat GET endpoint hydrates `files: ChatFileMetadata[]` on the response > 🤖 Created by Coder Agents and massaged into shape by a human.
10 lines
251 B
SQL
10 lines
251 B
SQL
ALTER TABLE chats ADD COLUMN file_ids uuid[] DEFAULT '{}'::uuid[] NOT NULL;
|
|
|
|
UPDATE chats SET file_ids = (
|
|
SELECT COALESCE(array_agg(cfl.file_id), '{}')
|
|
FROM chat_file_links cfl
|
|
WHERE cfl.chat_id = chats.id
|
|
);
|
|
|
|
DROP TABLE chat_file_links;
|