mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
d0a9f8c2cb
Drop the docOps collection GitOrigin-RevId: 8ffa0570ae58b6a00412d8953d3ea0fbb1869b69
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
const Path = require('path')
|
|
|
|
class Adapter {
|
|
constructor(params) {
|
|
if (
|
|
!process.env.SKIP_TAG_CHECK &&
|
|
!process.argv.includes('create') &&
|
|
!(process.argv.includes('-t') || process.argv.includes('--tags'))
|
|
) {
|
|
console.error("ERROR: must pass tags using '-t' or '--tags', exiting")
|
|
process.exit(1)
|
|
}
|
|
this.params = params || {}
|
|
}
|
|
|
|
getTemplatePath() {
|
|
return Path.resolve(__dirname, 'template.js')
|
|
}
|
|
|
|
async connect() {
|
|
const { waitForDb, db } = require('../../app/src/infrastructure/mongodb')
|
|
const { getNativeDb } = require('../../app/src/infrastructure/Mongoose')
|
|
await waitForDb()
|
|
const nativeDb = await getNativeDb()
|
|
return { db, nativeDb }
|
|
}
|
|
|
|
disconnect() {
|
|
return Promise.resolve()
|
|
}
|
|
|
|
async getExecutedMigrationNames() {
|
|
const { db } = await this.connect()
|
|
const migrations = await db.migrations
|
|
.find({}, { sort: { migratedAt: 1 }, projection: { name: 1 } })
|
|
.toArray()
|
|
return migrations.map(migration => migration.name)
|
|
}
|
|
|
|
async markExecuted(name) {
|
|
const { db } = await this.connect()
|
|
return db.migrations.insertOne({
|
|
name,
|
|
migratedAt: new Date(),
|
|
})
|
|
}
|
|
|
|
async unmarkExecuted(name) {
|
|
const { db } = await this.connect()
|
|
return db.migrations.deleteOne({
|
|
name,
|
|
})
|
|
}
|
|
}
|
|
|
|
module.exports = Adapter
|