Confused about migration!

Hello there,

When I run the migration it tells me:

Found 45993 documents to update
undefined documents updated

My “npm test -t migration” test fails, however I have found this is because the record it is looking at does NOT have a “lastUpdated” field… however it DOES have “tomatoes.lastUpdated” field… (If I change the test to look for this field instead then it passes!)

Despite this, my “/status/” test fails so I cannot complete the course, but I’m confused whether if the test script is wrong, is the “status” URL looking at the correct thing… ?

1 Like

Don’t ever change tests.

Why?

 expect(true).toBeTruthy();

There you go I just wrote a test that will always pass. THAT is why you don’t change tests, and ideally in the real world ( as in for paid $$$ work ) it should generally be expected that a “design spec” will define “unit tests” and a shape of an API, and it will be your job to “fill in the detail” as it were.

This is exactly why this course is presented in this way, with a “Ticket” raised for an issue, a skeleton API, and your job to fill in the parts that are needed to make that API work.


The task here is to actually update all the data in the collection.

You edit and run the script at: /src/migrations/movie-last-updated.js just like the question tells you to do. The field is of course called lastupdated ( all in lower case ) and not to be confused with lastUpdated, which is present in some of the documents. But that’s not the field you want here.

Then when the data is actually updated as expected, both the unit test and the /status page test will verify that the data they are expecting to have a “converted date” value. The migration is supposed to update ALL of the data that are presently “strings” to BSON Date objects, but the tests themselves are just looking at two individual documents.

Please read the other threads that mention migration. You’re not the first to do this, and you are not the first to ask. Actually reading will give you tips and help you, and most importantly help you avoid asking the “same questions” that others have already asked again.

Hi,

The migration ticket has two parts, i.e., TODOS. The first one ask for the proper predicate and projection. I guess you already did that one, but the second one ask you to complete the BulkWrite statement. I guess you missed that one. After you do that, just run movie-last-updated-migration.js with npm and then proceed to test.

I hope this helps.

2 Likes