mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #15748 from overleaf/em-drop-docops-collection
Drop the docOps collection GitOrigin-RevId: 8ffa0570ae58b6a00412d8953d3ea0fbb1869b69
This commit is contained in:
parent
af32433bfa
commit
d0a9f8c2cb
5 changed files with 24 additions and 18 deletions
|
@ -38,7 +38,6 @@ async function setupDb() {
|
|||
db.dropboxProjects = internalDb.collection('dropboxProjects')
|
||||
db.docHistory = internalDb.collection('docHistory')
|
||||
db.docHistoryIndex = internalDb.collection('docHistoryIndex')
|
||||
db.docOps = internalDb.collection('docOps')
|
||||
db.docSnapshots = internalDb.collection('docSnapshots')
|
||||
db.docs = internalDb.collection('docs')
|
||||
db.feedbacks = internalDb.collection('feedbacks')
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/* eslint-disable no-unused-vars */
|
||||
|
||||
const Helpers = require('./lib/helpers')
|
||||
|
||||
exports.tags = ['server-ce', 'server-pro', 'saas']
|
||||
|
@ -14,18 +12,12 @@ const indexes = [
|
|||
},
|
||||
]
|
||||
|
||||
exports.migrate = async client => {
|
||||
const { db } = client
|
||||
|
||||
await Helpers.addIndexesToCollection(db.docOps, indexes)
|
||||
exports.migrate = async ({ nativeDb }) => {
|
||||
const docOps = nativeDb.collection('docOps')
|
||||
await Helpers.addIndexesToCollection(docOps, indexes)
|
||||
}
|
||||
|
||||
exports.rollback = async client => {
|
||||
const { db } = client
|
||||
|
||||
try {
|
||||
await Helpers.dropIndexesFromCollection(db.docOps, indexes)
|
||||
} catch (err) {
|
||||
console.error('Something went wrong rolling back the migrations', err)
|
||||
}
|
||||
exports.rollback = async ({ nativeDb }) => {
|
||||
const docOps = nativeDb.collection('docOps')
|
||||
await Helpers.dropIndexesFromCollection(docOps, indexes)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
const { dropCollection } = require('./lib/helpers')
|
||||
|
||||
exports.tags = ['server-ce', 'server-pro', 'saas']
|
||||
|
||||
exports.migrate = async () => {
|
||||
await dropCollection('docOps')
|
||||
}
|
||||
|
||||
exports.rollback = async client => {
|
||||
// there's no rollback: we can't recover the data
|
||||
}
|
|
@ -5,12 +5,14 @@ const MIN_ID = process.env.MIN_ID
|
|||
|
||||
exports.tags = ['server-ce', 'server-pro', 'saas']
|
||||
|
||||
exports.migrate = async ({ db }) => {
|
||||
exports.migrate = async ({ db, nativeDb }) => {
|
||||
const docOps = nativeDb.collection('docOps')
|
||||
|
||||
const filter = {}
|
||||
if (MIN_ID) {
|
||||
filter._id = { $gte: new ObjectId(MIN_ID) }
|
||||
}
|
||||
const records = db.docOps
|
||||
const records = docOps
|
||||
.find(filter, { readPreference: ReadPreference.secondaryPreferred })
|
||||
.sort({ _id: 1 })
|
||||
|
||||
|
|
|
@ -19,8 +19,10 @@ class Adapter {
|
|||
|
||||
async connect() {
|
||||
const { waitForDb, db } = require('../../app/src/infrastructure/mongodb')
|
||||
const { getNativeDb } = require('../../app/src/infrastructure/Mongoose')
|
||||
await waitForDb()
|
||||
return { db }
|
||||
const nativeDb = await getNativeDb()
|
||||
return { db, nativeDb }
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
|
|
Loading…
Reference in a new issue