mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 04:03:34 -05:00
eea27a36a4
* Add `unicorn/prefer-node-protocol` * Revert non-web changes * Run `npm run lint:fix` (prefer-node-protocol) GitOrigin-RevId: c3cdd88ff9e6b3de6a4397d45935c4d026c1c1ed
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
import Path from 'node:path'
|
|
import { db } from '../../app/src/infrastructure/mongodb.js'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
const __dirname = Path.dirname(__filename)
|
|
|
|
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.mjs')
|
|
}
|
|
|
|
async connect() {
|
|
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,
|
|
migratedAt: new Date(),
|
|
})
|
|
}
|
|
|
|
async unmarkExecuted(name) {
|
|
return db.migrations.deleteOne({
|
|
name,
|
|
})
|
|
}
|
|
}
|
|
|
|
export default Adapter
|