Files
OwnCord/Server/db/dbgen/attachments.sql.go
T
J3vbandClaude Fable 5 9d8bbec375 chore(db): drop 18 sqlc queries with zero callers
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>
2026-07-23 15:29:01 +02:00

140 lines
3.5 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: attachments.sql
package dbgen
import (
"context"
)
const createAttachment = `-- name: CreateAttachment :exec
INSERT INTO attachments (id, uploader_id, filename, stored_as, mime_type, size, width, height)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
`
type CreateAttachmentParams struct {
ID string `json:"id"`
UploaderID *int64 `json:"uploaderId"`
Filename string `json:"filename"`
StoredAs string `json:"storedAs"`
MimeType string `json:"mimeType"`
Size int64 `json:"size"`
Width *int64 `json:"width"`
Height *int64 `json:"height"`
}
func (q *Queries) CreateAttachment(ctx context.Context, arg CreateAttachmentParams) error {
_, err := q.db.ExecContext(ctx, createAttachment,
arg.ID,
arg.UploaderID,
arg.Filename,
arg.StoredAs,
arg.MimeType,
arg.Size,
arg.Width,
arg.Height,
)
return err
}
const deleteOrphanedAttachments = `-- name: DeleteOrphanedAttachments :many
DELETE FROM attachments WHERE message_id IS NULL AND uploaded_at < ? RETURNING stored_as
`
func (q *Queries) DeleteOrphanedAttachments(ctx context.Context, uploadedAt string) ([]string, error) {
rows, err := q.db.QueryContext(ctx, deleteOrphanedAttachments, uploadedAt)
if err != nil {
return nil, err
}
defer rows.Close()
items := []string{}
for rows.Next() {
var stored_as string
if err := rows.Scan(&stored_as); err != nil {
return nil, err
}
items = append(items, stored_as)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getAttachmentByID = `-- name: GetAttachmentByID :one
SELECT id, message_id, filename, stored_as, mime_type, size, uploaded_at, uploader_id
FROM attachments WHERE id = ?
`
type GetAttachmentByIDRow struct {
ID string `json:"id"`
MessageID *int64 `json:"messageId"`
Filename string `json:"filename"`
StoredAs string `json:"storedAs"`
MimeType string `json:"mimeType"`
Size int64 `json:"size"`
UploadedAt string `json:"uploadedAt"`
UploaderID *int64 `json:"uploaderId"`
}
func (q *Queries) GetAttachmentByID(ctx context.Context, id string) (GetAttachmentByIDRow, error) {
row := q.db.QueryRowContext(ctx, getAttachmentByID, id)
var i GetAttachmentByIDRow
err := row.Scan(
&i.ID,
&i.MessageID,
&i.Filename,
&i.StoredAs,
&i.MimeType,
&i.Size,
&i.UploadedAt,
&i.UploaderID,
)
return i, err
}
const getAttachmentWithChannel = `-- 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 = ?
`
type GetAttachmentWithChannelRow struct {
ID string `json:"id"`
MessageID *int64 `json:"messageId"`
Filename string `json:"filename"`
StoredAs string `json:"storedAs"`
MimeType string `json:"mimeType"`
Size int64 `json:"size"`
UploadedAt string `json:"uploadedAt"`
UploaderID *int64 `json:"uploaderId"`
ChannelID *int64 `json:"channelId"`
Type *string `json:"type"`
}
func (q *Queries) GetAttachmentWithChannel(ctx context.Context, id string) (GetAttachmentWithChannelRow, error) {
row := q.db.QueryRowContext(ctx, getAttachmentWithChannel, id)
var i GetAttachmentWithChannelRow
err := row.Scan(
&i.ID,
&i.MessageID,
&i.Filename,
&i.StoredAs,
&i.MimeType,
&i.Size,
&i.UploadedAt,
&i.UploaderID,
&i.ChannelID,
&i.Type,
)
return i, err
}