fix(attachment): use UUIDv7 as S3 key and link attachments on issue/comment creation
- Use google/uuid NewV7() for attachment ID and S3 file key instead of random hex, so the S3 object name matches the attachment record ID - Add LinkAttachmentsToIssue query to associate orphaned attachments with a newly created issue - Pass attachment_ids in CreateIssue request so uploads during issue creation (before the issue exists) get linked after commit - Collect and pass attachment IDs in comment-input and reply-input so comment creation properly links uploaded files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5b0a537302
commit
4036d64996
10 changed files with 114 additions and 24 deletions
|
|
@ -1,6 +1,6 @@
|
|||
-- name: CreateAttachment :one
|
||||
INSERT INTO attachment (workspace_id, issue_id, comment_id, uploader_type, uploader_id, filename, url, content_type, size_bytes)
|
||||
VALUES ($1, sqlc.narg(issue_id), sqlc.narg(comment_id), $2, $3, $4, $5, $6, $7)
|
||||
INSERT INTO attachment (id, workspace_id, issue_id, comment_id, uploader_type, uploader_id, filename, url, content_type, size_bytes)
|
||||
VALUES ($1, $2, sqlc.narg(issue_id), sqlc.narg(comment_id), $3, $4, $5, $6, $7, $8)
|
||||
RETURNING *;
|
||||
|
||||
-- name: ListAttachmentsByIssue :many
|
||||
|
|
@ -38,5 +38,12 @@ WHERE issue_id = $2
|
|||
AND comment_id IS NULL
|
||||
AND id = ANY($3::uuid[]);
|
||||
|
||||
-- name: LinkAttachmentsToIssue :exec
|
||||
UPDATE attachment
|
||||
SET issue_id = $1
|
||||
WHERE workspace_id = $2
|
||||
AND issue_id IS NULL
|
||||
AND id = ANY($3::uuid[]);
|
||||
|
||||
-- name: DeleteAttachment :exec
|
||||
DELETE FROM attachment WHERE id = $1 AND workspace_id = $2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue