Skip to content

Commit

Permalink
update to be able to test a single user
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-bate committed Jan 8, 2024
1 parent 97cfc0c commit 0fff52b
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type Migration struct {
updates []mongo.WriteModel
dryRun bool
stopOnErr bool
migrateItemID string
lastUpdatedId string
}

Expand Down Expand Up @@ -162,6 +163,12 @@ func (m *Migration) Initialize() error {
//uri string comes from file called `uri`
FilePath: "./uri",
},
cli.StringFlag{
Name: "test-id",
Usage: "id of single user to migrate",
Destination: &m.migrateItemID,
Required: false,
},
)
return nil
}
Expand Down Expand Up @@ -364,8 +371,16 @@ func (m *Migration) blockUntilDBReady() error {
func (m *Migration) fetchAndUpdateBatch() bool {
selector := bson.M{
"_deduplicator": bson.M{"$exists": false},
// testing based on _userId for [email protected]
"_userId": "6d1ca155-68e6-4cd6-9ed2-1b8e743d5f4a",
}

if m.migrateItemID != "" {
selector["_userId"] = m.migrateItemID
log.Printf("setting id of single user %v ", selector)
}

if selector["_userId"] == nil {
log.Printf("testing so we need a user id %v", selector)
return false
}

// jellyfish uses a generated _id that is not an mongo objectId
Expand Down

0 comments on commit 0fff52b

Please sign in to comment.