|
@@ -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 tags = ['saas']
|
|
|
|
|
|
|
|
const migrate = async client => {
|
|
const migrate = async client => {
|
|
|
const { db } = client
|
|
const { db } = client
|
|
|
// 'recurly' -> 'recurlyStatus'
|
|
// 'recurly' -> 'recurlyStatus'
|
|
|
- await db.subscriptions.updateMany(
|
|
|
|
|
|
|
+ await batchedUpdate(
|
|
|
|
|
+ db.subscriptions,
|
|
|
{
|
|
{
|
|
|
$and: [
|
|
$and: [
|
|
|
{ recurlyStatus: { $exists: false } },
|
|
{ recurlyStatus: { $exists: false } },
|
|
@@ -17,7 +16,8 @@ const migrate = async client => {
|
|
|
{ $rename: { recurly: 'recurlyStatus' } }
|
|
{ $rename: { recurly: 'recurlyStatus' } }
|
|
|
)
|
|
)
|
|
|
// some records may have already recached the recurly status, discard old cache
|
|
// some records may have already recached the recurly status, discard old cache
|
|
|
- await db.subscriptions.updateMany(
|
|
|
|
|
|
|
+ await batchedUpdate(
|
|
|
|
|
+ db.subscriptions,
|
|
|
{
|
|
{
|
|
|
$and: [
|
|
$and: [
|
|
|
{ recurlyStatus: { $exists: true } },
|
|
{ recurlyStatus: { $exists: true } },
|
|
@@ -31,7 +31,8 @@ const migrate = async client => {
|
|
|
const rollback = async client => {
|
|
const rollback = async client => {
|
|
|
const { db } = client
|
|
const { db } = client
|
|
|
// 'recurlyStatus' -> 'recurly'
|
|
// 'recurlyStatus' -> 'recurly'
|
|
|
- await db.subscriptions.updateMany(
|
|
|
|
|
|
|
+ await batchedUpdate(
|
|
|
|
|
+ db.subscriptions,
|
|
|
{
|
|
{
|
|
|
$and: [
|
|
$and: [
|
|
|
{ recurly: { $exists: false } },
|
|
{ recurly: { $exists: false } },
|
|
@@ -41,7 +42,8 @@ const rollback = async client => {
|
|
|
{ $rename: { recurlyStatus: 'recurly' } }
|
|
{ $rename: { recurlyStatus: 'recurly' } }
|
|
|
)
|
|
)
|
|
|
// some records may have already recached the recurly status, discard old cache
|
|
// some records may have already recached the recurly status, discard old cache
|
|
|
- await db.subscriptions.updateMany(
|
|
|
|
|
|
|
+ await batchedUpdate(
|
|
|
|
|
+ db.subscriptions,
|
|
|
{
|
|
{
|
|
|
$and: [
|
|
$and: [
|
|
|
{ recurlyStatus: { $exists: true } },
|
|
{ recurlyStatus: { $exists: true } },
|