mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
Each verified: the generated dbgen method's only references were the .sql definition and dbgen output itself (no wrapper in db/*.go, no test, no script). ArchiveChannel, DeleteAttachment, FindExistingDMChannel, GetDefaultRole, GetMessagesByChannel, GetMessagesByChannelBeforeCursor, GetMessagesForAPIBeforeCursor, GetPinnedMessageRows, GetPlugin, GetPluginByName, InsertDMChannel, InsertDMOpenState, InsertDMParticipants, LinkAttachmentToMessage, SetChannelMixingThreshold, SetChannelVoiceMaxVideo, SetChannelVoiceQuality, UpdateVoiceSpeaking. dbgen regenerated with the pinned sqlc v1.30.0 (132 → 114 queries); sqlc-verify clean; db/service/ws suites green including -race. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
20 lines
737 B
SQL
20 lines
737 B
SQL
-- name: CreateAttachment :exec
|
|
INSERT INTO attachments (id, uploader_id, filename, stored_as, mime_type, size, width, height)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?);
|
|
|
|
-- name: GetAttachmentByID :one
|
|
SELECT id, message_id, filename, stored_as, mime_type, size, uploaded_at, uploader_id
|
|
FROM attachments WHERE id = ?;
|
|
|
|
-- name: GetAttachmentWithChannel :one
|
|
SELECT a.id, a.message_id, a.filename, a.stored_as, a.mime_type, a.size,
|
|
a.uploaded_at, a.uploader_id, m.channel_id, c.type
|
|
FROM attachments a
|
|
LEFT JOIN messages m ON m.id = a.message_id
|
|
LEFT JOIN channels c ON c.id = m.channel_id
|
|
WHERE a.id = ?;
|
|
|
|
-- name: DeleteOrphanedAttachments :many
|
|
DELETE FROM attachments WHERE message_id IS NULL AND uploaded_at < ? RETURNING stored_as;
|
|
|