Skip to content

Commit ecf11f9

Browse files
nleroy917Anush008
andauthored
chore: delete offsets collection after successful migration (#190)
* Improve elastic/open search error handling Signed-off-by: Nathan LeRoy <nleroy917@users.noreply.github.com> * chore: Lint Signed-off-by: Anush008 <anushshetty90@gmail.com> * add helper to delete offset collection * add offsets deletion to all methods --------- Signed-off-by: Nathan LeRoy <nleroy917@users.noreply.github.com> Signed-off-by: Anush008 <anushshetty90@gmail.com> Co-authored-by: Nathan LeRoy <nleroy917@users.noreply.github.com> Co-authored-by: Anush008 <anushshetty90@gmail.com>
1 parent 6e5c707 commit ecf11f9

12 files changed

+69
-0
lines changed

cmd/migrate_from_elasticsearch.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ func (r *MigrateFromElasticsearchCmd) Run(globals *Globals) error {
100100

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

103+
err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
104+
if err != nil {
105+
return fmt.Errorf("failed to delete migration marker collection: %w", err)
106+
}
107+
103108
return nil
104109
}
105110

cmd/migrate_from_faiss.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ func (r *MigrateFromFaissCmd) Run(globals *Globals) error {
9696
}
9797

9898
pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)
99+
100+
err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
101+
if err != nil {
102+
return fmt.Errorf("failed to delete migration marker collection: %w", err)
103+
}
104+
99105
return nil
100106
}
101107

cmd/migrate_from_milvus.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ func (r *MigrateFromMilvusCmd) Run(globals *Globals) error {
9898

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

101+
err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
102+
if err != nil {
103+
return fmt.Errorf("failed to delete migration marker collection: %w", err)
104+
}
105+
101106
return nil
102107
}
103108

cmd/migrate_from_mongo.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ func (r *MigrateFromMongoDBCmd) Run(globals *Globals) error {
9999

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

102+
err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
103+
if err != nil {
104+
return fmt.Errorf("failed to delete migration marker collection: %w", err)
105+
}
106+
102107
return nil
103108
}
104109

cmd/migrate_from_opensearch.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ func (r *MigrateFromOpenSearchCmd) Run(globals *Globals) error {
9898

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

101+
err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
102+
if err != nil {
103+
return fmt.Errorf("failed to delete migration marker collection: %w", err)
104+
}
105+
101106
return nil
102107
}
103108

cmd/migrate_from_pg.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ func (r *MigrateFromPGCmd) Run(globals *Globals) error {
9999

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

102+
err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
103+
if err != nil {
104+
return fmt.Errorf("failed to delete migration marker collection: %w", err)
105+
}
106+
102107
return nil
103108
}
104109

cmd/migrate_from_pinecone.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ func (r *MigrateFromPineconeCmd) Run(globals *Globals) error {
9595

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

98+
err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
99+
if err != nil {
100+
return fmt.Errorf("failed to delete migration marker collection: %w", err)
101+
}
102+
98103
return nil
99104
}
100105

cmd/migrate_from_qdrant.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ func (r *MigrateFromQdrantCmd) Run(globals *Globals) error {
127127
}
128128

129129
pterm.Info.Printfln("Target collection has %d points\n", targetPointCount)
130+
131+
err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
132+
if err != nil {
133+
return fmt.Errorf("failed to delete migration marker collection: %w", err)
134+
}
135+
130136
return nil
131137
}
132138

cmd/migrate_from_redis.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ func (r *MigrateFromRedisCmd) Run(globals *Globals) error {
107107

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

110+
err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
111+
if err != nil {
112+
return fmt.Errorf("failed to delete migration marker collection: %w", err)
113+
}
114+
110115
return nil
111116
}
112117

cmd/migrate_from_s3_vectors.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ func (r *MigrateFromS3VectorsCmd) Run(globals *Globals) error {
9292

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

95+
err = commons.DeleteOffsetsCollection(ctx, r.Migration.OffsetsCollection, targetClient)
96+
if err != nil {
97+
return fmt.Errorf("failed to delete migration marker collection: %w", err)
98+
}
99+
95100
return nil
96101
}
97102

0 commit comments

Comments
 (0)