mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
[web] migration fixes (#26443)
* [web] fix typo in ESM migration of a db migration * [web] migrate old migration to ESM * [web] use batchedUpdate for bulk updates in old migrations GitOrigin-RevId: a984f785c577c2ac4125c947b8a3efffa57e1eb7
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import updateStringDates from '../scripts/confirmed_at_to_dates.mjs'
|
||||
import updateStringDates from '../scripts/split_tests_assigned_at_to_dates.mjs'
|
||||
|
||||
const tags = ['saas']
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
|
||||
import Helpers from './lib/helpers.mjs'
|
||||
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
||||
|
||||
const tags = ['saas']
|
||||
|
||||
const migrate = async client => {
|
||||
const { db } = client
|
||||
// 'recurly' -> 'recurlyStatus'
|
||||
await db.subscriptions.updateMany(
|
||||
await batchedUpdate(
|
||||
db.subscriptions,
|
||||
{
|
||||
$and: [
|
||||
{ recurlyStatus: { $exists: false } },
|
||||
@@ -17,7 +16,8 @@ const migrate = async client => {
|
||||
{ $rename: { recurly: 'recurlyStatus' } }
|
||||
)
|
||||
// some records may have already recached the recurly status, discard old cache
|
||||
await db.subscriptions.updateMany(
|
||||
await batchedUpdate(
|
||||
db.subscriptions,
|
||||
{
|
||||
$and: [
|
||||
{ recurlyStatus: { $exists: true } },
|
||||
@@ -31,7 +31,8 @@ const migrate = async client => {
|
||||
const rollback = async client => {
|
||||
const { db } = client
|
||||
// 'recurlyStatus' -> 'recurly'
|
||||
await db.subscriptions.updateMany(
|
||||
await batchedUpdate(
|
||||
db.subscriptions,
|
||||
{
|
||||
$and: [
|
||||
{ recurly: { $exists: false } },
|
||||
@@ -41,7 +42,8 @@ const rollback = async client => {
|
||||
{ $rename: { recurlyStatus: 'recurly' } }
|
||||
)
|
||||
// some records may have already recached the recurly status, discard old cache
|
||||
await db.subscriptions.updateMany(
|
||||
await batchedUpdate(
|
||||
db.subscriptions,
|
||||
{
|
||||
$and: [
|
||||
{ recurlyStatus: { $exists: true } },
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
|
||||
import Helpers from './lib/helpers.mjs'
|
||||
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
||||
|
||||
const tags = ['saas']
|
||||
|
||||
const migrate = async client => {
|
||||
const { db } = client
|
||||
db.subscriptions.updateMany(
|
||||
await batchedUpdate(
|
||||
db.subscriptions,
|
||||
{
|
||||
'teamInvites.0': {
|
||||
$exists: true,
|
||||
@@ -36,7 +35,7 @@ const migrate = async client => {
|
||||
)
|
||||
}
|
||||
|
||||
const rollback = async client => {
|
||||
const rollback = async () => {
|
||||
// There is no way back.
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
||||
|
||||
const tags = ['saas']
|
||||
|
||||
const migrate = async client => {
|
||||
const { db } = client
|
||||
await db.subscriptions.updateMany(
|
||||
await batchedUpdate(
|
||||
db.subscriptions,
|
||||
{ 'features.managedUsers': { $ne: true } },
|
||||
{ $set: { 'features.managedUsers': null } }
|
||||
)
|
||||
@@ -10,7 +13,8 @@ const migrate = async client => {
|
||||
|
||||
const rollback = async client => {
|
||||
const { db } = client
|
||||
await db.subscriptions.updateMany(
|
||||
await batchedUpdate(
|
||||
db.subscriptions,
|
||||
{ 'features.managedUsers': { $eq: null } },
|
||||
{ $set: { 'features.managedUsers': false } }
|
||||
)
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
||||
|
||||
const tags = ['saas']
|
||||
|
||||
const migrate = async client => {
|
||||
const { db } = client
|
||||
await db.ssoConfigs.updateMany(
|
||||
await batchedUpdate(
|
||||
db.ssoConfigs,
|
||||
{ certificate: { $exists: true }, certificates: { $exists: false } },
|
||||
[
|
||||
{ $set: { certificates: ['$certificate'] } },
|
||||
@@ -11,11 +14,13 @@ const migrate = async client => {
|
||||
},
|
||||
]
|
||||
)
|
||||
await db.ssoConfigs.updateMany(
|
||||
await batchedUpdate(
|
||||
db.ssoConfigs,
|
||||
{ userFirstNameAttribute: null },
|
||||
{ $unset: { userFirstNameAttribute: true } }
|
||||
)
|
||||
await db.ssoConfigs.updateMany(
|
||||
await batchedUpdate(
|
||||
db.ssoConfigs,
|
||||
{ userLastNameAttribute: null },
|
||||
{ $unset: { userLastNameAttribute: true } }
|
||||
)
|
||||
@@ -23,7 +28,8 @@ const migrate = async client => {
|
||||
|
||||
const rollback = async client => {
|
||||
const { db } = client
|
||||
await db.ssoConfigs.updateMany(
|
||||
await batchedUpdate(
|
||||
db.ssoConfigs,
|
||||
{ certificate: { $exists: false }, certificates: { $exists: true } },
|
||||
[
|
||||
{ $set: { certificate: { $arrayElemAt: ['$certificates', 0] } } },
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
|
||||
import Helpers from './lib/helpers.mjs'
|
||||
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
||||
|
||||
const tags = ['saas']
|
||||
|
||||
const migrate = async client => {
|
||||
const { db } = client
|
||||
await db.subscriptions.updateMany(
|
||||
await batchedUpdate(
|
||||
db.subscriptions,
|
||||
{ groupPolicy: { $exists: true } },
|
||||
{ $set: { managedUsersEnabled: true } }
|
||||
)
|
||||
@@ -14,7 +13,8 @@ const migrate = async client => {
|
||||
|
||||
const rollback = async client => {
|
||||
const { db } = client
|
||||
await db.subscriptions.updateMany(
|
||||
await batchedUpdate(
|
||||
db.subscriptions,
|
||||
{ groupPolicy: { $exists: true } },
|
||||
{ $unset: { managedUsersEnabled: '' } }
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Helpers = require('./lib/helpers')
|
||||
import Helpers from './lib/helpers.mjs'
|
||||
|
||||
exports.tags = ['server-ce', 'server-pro', 'saas']
|
||||
const tags = ['server-ce', 'server-pro', 'saas']
|
||||
|
||||
const indexes = [
|
||||
{
|
||||
@@ -9,12 +9,18 @@ const indexes = [
|
||||
},
|
||||
]
|
||||
|
||||
exports.migrate = async client => {
|
||||
async function migrate(client) {
|
||||
const { db } = client
|
||||
await Helpers.addIndexesToCollection(db.users, indexes)
|
||||
}
|
||||
|
||||
exports.rollback = async client => {
|
||||
async function rollback(client) {
|
||||
const { db } = client
|
||||
await Helpers.dropIndexesFromCollection(db.users, indexes)
|
||||
}
|
||||
|
||||
export default {
|
||||
tags,
|
||||
migrate,
|
||||
rollback,
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
||||
|
||||
const tags = ['saas']
|
||||
|
||||
const migrate = async client => {
|
||||
const { db } = client
|
||||
await db.subscriptions.updateMany(
|
||||
await batchedUpdate(
|
||||
db.subscriptions,
|
||||
{ 'features.managedUsers': { $eq: null } },
|
||||
{ $set: { 'features.managedUsers': true } }
|
||||
)
|
||||
await db.subscriptions.updateMany(
|
||||
await batchedUpdate(
|
||||
db.subscriptions,
|
||||
{ 'features.groupSSO': { $eq: null } },
|
||||
{ $set: { 'features.groupSSO': true } }
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user