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
55 lines
1.7 KiB
SQL
55 lines
1.7 KiB
SQL
-- name: UpsertContainer :exec
|
|
INSERT INTO containers (
|
|
bot_id, container_id, container_name, image, status, namespace, auto_start,
|
|
host_path, container_path, last_started_at, last_stopped_at
|
|
)
|
|
VALUES (
|
|
sqlc.arg(bot_id),
|
|
sqlc.arg(container_id),
|
|
sqlc.arg(container_name),
|
|
sqlc.arg(image),
|
|
sqlc.arg(status),
|
|
sqlc.arg(namespace),
|
|
sqlc.arg(auto_start),
|
|
sqlc.arg(host_path),
|
|
sqlc.arg(container_path),
|
|
sqlc.arg(last_started_at),
|
|
sqlc.arg(last_stopped_at)
|
|
)
|
|
ON CONFLICT (container_id) DO UPDATE SET
|
|
bot_id = EXCLUDED.bot_id,
|
|
container_name = EXCLUDED.container_name,
|
|
image = EXCLUDED.image,
|
|
status = EXCLUDED.status,
|
|
namespace = EXCLUDED.namespace,
|
|
auto_start = EXCLUDED.auto_start,
|
|
host_path = EXCLUDED.host_path,
|
|
container_path = EXCLUDED.container_path,
|
|
last_started_at = EXCLUDED.last_started_at,
|
|
last_stopped_at = EXCLUDED.last_stopped_at,
|
|
updated_at = now();
|
|
|
|
-- name: GetContainerByBotID :one
|
|
SELECT * FROM containers WHERE bot_id = sqlc.arg(bot_id) ORDER BY updated_at DESC LIMIT 1;
|
|
|
|
-- name: DeleteContainerByBotID :exec
|
|
DELETE FROM containers WHERE bot_id = sqlc.arg(bot_id);
|
|
|
|
-- name: UpdateContainerStatus :exec
|
|
UPDATE containers
|
|
SET status = sqlc.arg(status), updated_at = now()
|
|
WHERE bot_id = sqlc.arg(bot_id);
|
|
|
|
-- name: UpdateContainerStarted :exec
|
|
UPDATE containers
|
|
SET status = 'running', last_started_at = now(), updated_at = now()
|
|
WHERE bot_id = sqlc.arg(bot_id);
|
|
|
|
-- name: UpdateContainerStopped :exec
|
|
UPDATE containers
|
|
SET status = 'stopped', last_stopped_at = now(), updated_at = now()
|
|
WHERE bot_id = sqlc.arg(bot_id);
|
|
|
|
-- name: ListAutoStartContainers :many
|
|
SELECT * FROM containers WHERE auto_start = true ORDER BY updated_at DESC;
|