mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
eef5cd00e3
[migrations] delete unused collections and properly apply saml indexes GitOrigin-RevId: eafcde98cbb603c275986a5bca708b9f8221877f
51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
const Path = require('path')
|
|
const { waitForDb, db } = require('../../app/src/infrastructure/mongodb')
|
|
|
|
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() {
|
|
await waitForDb()
|
|
return { db }
|
|
}
|
|
|
|
disconnect() {
|
|
return Promise.resolve()
|
|
}
|
|
|
|
async getExecutedMigrationNames() {
|
|
const migrations = await db.migrations
|
|
.find({}, { sort: { migratedAt: 1 }, projection: { name: 1 } })
|
|
.toArray()
|
|
return migrations.map(migration => migration.name)
|
|
}
|
|
|
|
async markExecuted(name) {
|
|
return db.migrations.insertOne({
|
|
name: name,
|
|
migratedAt: new Date(),
|
|
})
|
|
}
|
|
|
|
async unmarkExecuted(name) {
|
|
return db.migrations.deleteOne({
|
|
name: name,
|
|
})
|
|
}
|
|
}
|
|
|
|
module.exports = Adapter
|