mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
85251a2905
- Remove user-level model settings (chat_model_id, memory_model_id, embedding_model_id, max_context_load_time, language) from users table - Merge migration 0002 into 0001, remove compatibility migrations - Delete dead conversation/resolver.go (1177 lines, only flow/resolver.go used) - Remove type aliases (Chat=Conversation, types_alias.go) - Fix SQL: remove AND false stub, fix UpdateChatTitle model_id, reset model IDs in DeleteSettings, add preauth expiry filter, add ListMessages limit, remove 10 dead queries - Extract shared handler helpers (RequireChannelIdentityID, AuthorizeBotAccess) - Rename internal/router to internal/channel/inbound - Fix identity confusion: remove UserID->ChannelIdentityID fallbacks - Fix all _ = var patterns with proper error logging - Fix error propagation: storeMessages, rescheduleJob, botContainerID - Fix naming: ModelId->ModelID, active->is_active, Duration semantic fix - Remove dead code: mcpService, ReplyTarget, callMCPServer, sshShellQuote, buildSessionMetadata, ChatRequest.Language, TriggerPayload.ChatID - Fix code quality: errors.Is(), remove goto, CreateHuman deprecated - Remove Enable model endpoint and user-level settings CLI commands - Regenerate sqlc, swagger, SDK
46 lines
2.0 KiB
SQL
46 lines
2.0 KiB
SQL
-- name: CreateChannelIdentity :one
|
|
INSERT INTO channel_identities (user_id, channel_type, channel_subject_id, display_name, avatar_url, metadata)
|
|
VALUES ($1, $2, $3, $4, $5, $6)
|
|
RETURNING id, user_id, channel_type, channel_subject_id, display_name, avatar_url, metadata, created_at, updated_at;
|
|
|
|
-- name: GetChannelIdentityByID :one
|
|
SELECT id, user_id, channel_type, channel_subject_id, display_name, avatar_url, metadata, created_at, updated_at
|
|
FROM channel_identities
|
|
WHERE id = $1;
|
|
|
|
-- name: GetChannelIdentityByIDForUpdate :one
|
|
SELECT id, user_id, channel_type, channel_subject_id, display_name, avatar_url, metadata, created_at, updated_at
|
|
FROM channel_identities
|
|
WHERE id = $1
|
|
FOR UPDATE;
|
|
|
|
-- name: GetChannelIdentityByChannelSubject :one
|
|
SELECT id, user_id, channel_type, channel_subject_id, display_name, avatar_url, metadata, created_at, updated_at
|
|
FROM channel_identities
|
|
WHERE channel_type = $1 AND channel_subject_id = $2;
|
|
|
|
-- name: UpsertChannelIdentityByChannelSubject :one
|
|
INSERT INTO channel_identities (user_id, channel_type, channel_subject_id, display_name, avatar_url, metadata)
|
|
VALUES ($1, $2, $3, $4, $5, $6)
|
|
ON CONFLICT (channel_type, channel_subject_id)
|
|
DO UPDATE SET
|
|
display_name = COALESCE(NULLIF(EXCLUDED.display_name, ''), channel_identities.display_name),
|
|
avatar_url = COALESCE(NULLIF(EXCLUDED.avatar_url, ''), channel_identities.avatar_url),
|
|
metadata = EXCLUDED.metadata,
|
|
user_id = COALESCE(channel_identities.user_id, EXCLUDED.user_id),
|
|
updated_at = now()
|
|
RETURNING id, user_id, channel_type, channel_subject_id, display_name, avatar_url, metadata, created_at, updated_at;
|
|
|
|
-- name: ListChannelIdentitiesByUserID :many
|
|
SELECT id, user_id, channel_type, channel_subject_id, display_name, avatar_url, metadata, created_at, updated_at
|
|
FROM channel_identities
|
|
WHERE user_id = $1
|
|
ORDER BY created_at DESC;
|
|
|
|
-- name: SetChannelIdentityLinkedUser :one
|
|
UPDATE channel_identities
|
|
SET user_id = $2, updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, user_id, channel_type, channel_subject_id, display_name, avatar_url, metadata, created_at, updated_at;
|
|
|