mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
fix: drop sql & qdrant
This commit is contained in:
@@ -8,7 +8,6 @@ DROP TABLE IF EXISTS containers;
|
|||||||
DROP TABLE IF EXISTS channel_sessions;
|
DROP TABLE IF EXISTS channel_sessions;
|
||||||
DROP TABLE IF EXISTS contact_channels;
|
DROP TABLE IF EXISTS contact_channels;
|
||||||
DROP TABLE IF EXISTS bot_preauth_keys;
|
DROP TABLE IF EXISTS bot_preauth_keys;
|
||||||
DROP TABLE IF EXISTS contacts;
|
|
||||||
DROP TABLE IF EXISTS bot_channel_configs;
|
DROP TABLE IF EXISTS bot_channel_configs;
|
||||||
DROP TABLE IF EXISTS user_channel_bindings;
|
DROP TABLE IF EXISTS user_channel_bindings;
|
||||||
DROP TABLE IF EXISTS history;
|
DROP TABLE IF EXISTS history;
|
||||||
@@ -16,9 +15,11 @@ DROP TABLE IF EXISTS conversations;
|
|||||||
DROP TABLE IF EXISTS bot_model_configs;
|
DROP TABLE IF EXISTS bot_model_configs;
|
||||||
DROP TABLE IF EXISTS bot_settings;
|
DROP TABLE IF EXISTS bot_settings;
|
||||||
DROP TABLE IF EXISTS bot_members;
|
DROP TABLE IF EXISTS bot_members;
|
||||||
|
DROP TABLE IF EXISTS contact_bind_tokens;
|
||||||
DROP TABLE IF EXISTS bots;
|
DROP TABLE IF EXISTS bots;
|
||||||
DROP TABLE IF EXISTS model_variants;
|
|
||||||
DROP TABLE IF EXISTS models;
|
|
||||||
DROP TABLE IF EXISTS llm_providers;
|
|
||||||
DROP TABLE IF EXISTS users;
|
DROP TABLE IF EXISTS users;
|
||||||
|
DROP TABLE IF EXISTS contacts;
|
||||||
|
-- DROP TABLE IF EXISTS model_variants;
|
||||||
|
-- DROP TABLE IF EXISTS models;
|
||||||
|
-- DROP TABLE IF EXISTS llm_providers;
|
||||||
DROP TYPE IF EXISTS user_role;
|
DROP TYPE IF EXISTS user_role;
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/qdrant/go-client/qdrant"
|
"github.com/qdrant/go-client/qdrant"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -396,7 +398,10 @@ func (s *QdrantStore) ensureCollection(ctx context.Context, vectors map[string]i
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if exists {
|
if exists {
|
||||||
return s.refreshCollectionSchema(ctx, vectors)
|
if err := s.refreshCollectionSchema(ctx, vectors); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return s.ensurePayloadIndexes(ctx)
|
||||||
}
|
}
|
||||||
var vectorsConfig *qdrant.VectorsConfig
|
var vectorsConfig *qdrant.VectorsConfig
|
||||||
if len(vectors) > 0 {
|
if len(vectors) > 0 {
|
||||||
@@ -421,11 +426,14 @@ func (s *QdrantStore) ensureCollection(ctx context.Context, vectors map[string]i
|
|||||||
sparseVocabVectorName: {Modifier: qdrant.PtrOf(qdrant.Modifier_None)},
|
sparseVocabVectorName: {Modifier: qdrant.PtrOf(qdrant.Modifier_None)},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return s.client.CreateCollection(ctx, &qdrant.CreateCollection{
|
if err := s.client.CreateCollection(ctx, &qdrant.CreateCollection{
|
||||||
CollectionName: s.collection,
|
CollectionName: s.collection,
|
||||||
VectorsConfig: vectorsConfig,
|
VectorsConfig: vectorsConfig,
|
||||||
SparseVectorsConfig: sparseConfig,
|
SparseVectorsConfig: sparseConfig,
|
||||||
})
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return s.ensurePayloadIndexes(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *QdrantStore) refreshCollectionSchema(ctx context.Context, vectors map[string]int) error {
|
func (s *QdrantStore) refreshCollectionSchema(ctx context.Context, vectors map[string]int) error {
|
||||||
@@ -494,6 +502,34 @@ sparseCheck:
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *QdrantStore) ensurePayloadIndexes(ctx context.Context) error {
|
||||||
|
if s.client == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
fields := []string{"botId", "sessionId", "runId"}
|
||||||
|
wait := true
|
||||||
|
for _, field := range fields {
|
||||||
|
_, err := s.client.CreateFieldIndex(ctx, &qdrant.CreateFieldIndexCollection{
|
||||||
|
CollectionName: s.collection,
|
||||||
|
FieldName: field,
|
||||||
|
FieldType: qdrant.FieldType_FieldTypeKeyword.Enum(),
|
||||||
|
Wait: &wait,
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if status.Code(err) == codes.AlreadyExists {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// Fall back to string match when the backend wraps the error.
|
||||||
|
if strings.Contains(strings.ToLower(err.Error()), "already exists") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *QdrantStore) ensureSparseVectors(ctx context.Context) error {
|
func (s *QdrantStore) ensureSparseVectors(ctx context.Context) error {
|
||||||
if s.sparseVectorName == "" {
|
if s.sparseVectorName == "" {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
Reference in New Issue
Block a user