UpdateMany in mongodb using value of other field

I have this document in mongodb:

_id: “xxxx”, “timestamp”: ISODate(“2022-03-26T10:33:47.738Z”)

I would like to create a migration that will copy over timestamp to timestamp2 field. Something like this:

db.task.updateMany(
  { "timestamp2": { $exists: false } },
  { $set: { "timestamp2": $timestamp }}
)

So if document 1 have 2022-03-26T10:33:47.738Z as timestamp, its timestamp2 will be the same (2022-03-26T10:33:47.738Z). If document 2 have 2021-03-26T10:33:47.738Z as timestamp, its timestamp2 will be the same (2021-03-26T10:33:47.738Z) How can I achieve this? How can I rollback this migration (whats the code for the migrate-down file?) Thanks

Hi,
please refer to