mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
[web] switch migrations for fixing dates to batchedUpdate (#26582)
* [web] switch migration for fixing confirmedAt dates to batchedUpdate * [web] switch migration for fixing assignedAt dates to batchedUpdate * [web] make eslint happy GitOrigin-RevId: d898d28dc2aa1084e8d3af20b98f49e3fda8a1c6
This commit is contained in:
@@ -1,12 +1,35 @@
|
||||
import updateStringDates from '../scripts/confirmed_at_to_dates.mjs'
|
||||
import { db } from '../app/src/infrastructure/mongodb.js'
|
||||
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
||||
|
||||
const tags = ['saas']
|
||||
|
||||
const migrate = async client => {
|
||||
await updateStringDates()
|
||||
const migrate = async () => {
|
||||
await batchedUpdate(
|
||||
db.users,
|
||||
{ 'emails.confirmedAt': { $type: 'string' } },
|
||||
async function (batch) {
|
||||
for (const user of batch) {
|
||||
for (const email of user.emails) {
|
||||
if (typeof email.confirmedAt === 'string') {
|
||||
await db.users.updateOne(
|
||||
{ _id: user._id, 'emails.email': email.email },
|
||||
{
|
||||
$set: {
|
||||
'emails.$.confirmedAt': new Date(
|
||||
email.confirmedAt.replace(/ UTC$/, '')
|
||||
),
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{ emails: 1 }
|
||||
)
|
||||
}
|
||||
|
||||
const rollback = async client => {
|
||||
const rollback = async () => {
|
||||
/* nothing to do */
|
||||
}
|
||||
|
||||
|
||||
+21
-4
@@ -1,12 +1,29 @@
|
||||
import updateStringDates from '../scripts/split_tests_assigned_at_to_dates.mjs'
|
||||
import { db } from '../app/src/infrastructure/mongodb.js'
|
||||
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
||||
|
||||
const tags = ['saas']
|
||||
|
||||
const migrate = async client => {
|
||||
await updateStringDates()
|
||||
const migrate = async () => {
|
||||
await batchedUpdate(
|
||||
db.users,
|
||||
{ splitTests: { $exists: true } },
|
||||
async function (batch) {
|
||||
for (const user of batch) {
|
||||
const splitTests = user.splitTests
|
||||
for (const splitTest of Object.values(user.splitTests)) {
|
||||
for (const variant of splitTest) {
|
||||
variant.assignedAt = new Date(variant.assignedAt)
|
||||
}
|
||||
}
|
||||
|
||||
await db.users.updateOne({ _id: user._id }, { $set: { splitTests } })
|
||||
}
|
||||
},
|
||||
{ splitTests: 1 }
|
||||
)
|
||||
}
|
||||
|
||||
const rollback = async client => {
|
||||
const rollback = async () => {
|
||||
/* nothing to do */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user