mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-09-03 20:22:16 +00:00
- Add migration 000048: vault_documents.path_basename + vault_links.metadata (PG) - Update SQLite schema.sql: add path_basename, metadata columns + v15→v16 markers - Add schema.go backfill: loop-patch v15→v16 + basename extraction for existing docs - Update vault_documents store: SELECT/INSERT with path_basename (PG + SQLite) - Update vault_links store: SELECT/INSERT with metadata (PG + SQLite) - Add vault_source_cleanup: helper to purge orphaned sources + links by source ID - Add basename_helper.go + test: extract filename from path for DB sync - Update version.go: RequiredSchemaVersion → 48, SQLite SchemaVersion → 16 - Update vault_store.go: DeleteLinksBySource + BatchFindByDelegationIDs interface
28 lines
932 B
Go
28 lines
932 B
Go
//go:build sqlite || sqliteonly
|
|
|
|
package sqlitestore
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
// ComputeAttachmentBaseName derives the canonical basename used for both
|
|
// team_task_attachments.base_name and vault_documents.path_basename on SQLite.
|
|
//
|
|
// PG GENERATES these columns via `lower(regexp_replace(path, '.+/', ''))`.
|
|
// modernc.org/sqlite (bundled) ships no regexp_replace, so SQLite callers
|
|
// must compute the value app-side at INSERT/UPDATE time. This helper is the
|
|
// single source of truth — call it from workspace_interceptor, team_tasks_create,
|
|
// vault UpsertDocument, and v15→v16 migration backfill.
|
|
//
|
|
// Pure string manipulation; safe to invoke from PG code paths too where it
|
|
// becomes a harmless no-op (PG's GENERATED column overrides anything the Go
|
|
// caller supplies).
|
|
func ComputeAttachmentBaseName(path string) string {
|
|
if path == "" {
|
|
return ""
|
|
}
|
|
return strings.ToLower(filepath.Base(path))
|
|
}
|