Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/migrate_from_elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func (r *MigrateFromElasticsearchCmd) Run(globals *Globals) error {

pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)

err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
if err != nil {
return fmt.Errorf("failed to delete migration marker collection: %w", err)
}

return nil
}

Expand Down
6 changes: 6 additions & 0 deletions cmd/migrate_from_faiss.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ func (r *MigrateFromFaissCmd) Run(globals *Globals) error {
}

pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)

err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
if err != nil {
return fmt.Errorf("failed to delete migration marker collection: %w", err)
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/migrate_from_milvus.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func (r *MigrateFromMilvusCmd) Run(globals *Globals) error {

pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)

err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
if err != nil {
return fmt.Errorf("failed to delete migration marker collection: %w", err)
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/migrate_from_mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ func (r *MigrateFromMongoDBCmd) Run(globals *Globals) error {

pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)

err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
if err != nil {
return fmt.Errorf("failed to delete migration marker collection: %w", err)
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/migrate_from_opensearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func (r *MigrateFromOpenSearchCmd) Run(globals *Globals) error {

pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)

err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
if err != nil {
return fmt.Errorf("failed to delete migration marker collection: %w", err)
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/migrate_from_pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ func (r *MigrateFromPGCmd) Run(globals *Globals) error {

pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)

err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
if err != nil {
return fmt.Errorf("failed to delete migration marker collection: %w", err)
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/migrate_from_pinecone.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ func (r *MigrateFromPineconeCmd) Run(globals *Globals) error {

pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)

err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
if err != nil {
return fmt.Errorf("failed to delete migration marker collection: %w", err)
}

return nil
}

Expand Down
6 changes: 6 additions & 0 deletions cmd/migrate_from_qdrant.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ func (r *MigrateFromQdrantCmd) Run(globals *Globals) error {
}

pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)

err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
if err != nil {
return fmt.Errorf("failed to delete migration marker collection: %w", err)
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/migrate_from_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ func (r *MigrateFromRedisCmd) Run(globals *Globals) error {

pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)

err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
if err != nil {
return fmt.Errorf("failed to delete migration marker collection: %w", err)
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/migrate_from_s3_vectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ func (r *MigrateFromS3VectorsCmd) Run(globals *Globals) error {

pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)

err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
if err != nil {
return fmt.Errorf("failed to delete migration marker collection: %w", err)
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/migrate_from_weaviate.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func (r *MigrateFromWeaviateCmd) Run(globals *Globals) error {

pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)

err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
if err != nil {
return fmt.Errorf("failed to delete migration marker collection: %w", err)
}

return nil
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/commons/offsets.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ func PrepareOffsetsCollection(ctx context.Context, migrationOffsetsCollectionNam
})
}

func DeleteOffsetsCollection(ctx context.Context, migrationOffsetsCollectionName string, targetClient *qdrant.Client) error {
migrationOffsetCollectionExists, err := targetClient.CollectionExists(ctx, migrationOffsetsCollectionName)
if err != nil {
return fmt.Errorf("failed to check if collection exists: %w", err)
}
if !migrationOffsetCollectionExists {
fmt.Printf("Collection %s does not exist, nothing to delete\n", migrationOffsetsCollectionName)
return nil
}
return targetClient.DeleteCollection(ctx, migrationOffsetsCollectionName)
}

func GetStartOffset(ctx context.Context, migrationOffsetsCollectionName string, targetClient *qdrant.Client, sourceCollection string) (*qdrant.PointId, uint64, error) {
point, err := getOffsetPoint(ctx, migrationOffsetsCollectionName, targetClient, sourceCollection)
if err != nil {
Expand Down
Loading