2023-11-02 08:47:39 -04:00
|
|
|
/* eslint-disable no-unused-vars */
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
import Helpers from './lib/helpers.mjs'
|
2023-11-02 08:47:39 -04:00
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const tags = ['server-ce', 'server-pro', 'saas']
|
2023-11-02 08:47:39 -04:00
|
|
|
|
|
|
|
const DOCS_INDEXES = [
|
|
|
|
{
|
|
|
|
key: { project_id: 1 },
|
|
|
|
name: 'project_id_1',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
const TAGS_INDEXES = [
|
|
|
|
{
|
|
|
|
key: { user_id: 1 },
|
|
|
|
name: 'user_id_1',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
const PROJECTS_INDEXES = [
|
|
|
|
{
|
|
|
|
key: { _id: 1, lastOpened: 1, active: 1 },
|
|
|
|
name: '_id_1_lastOpened_1_active_1',
|
|
|
|
partialFilterExpression: { active: true },
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const migrate = async ({ db }) => {
|
2023-11-02 08:47:39 -04:00
|
|
|
await Helpers.dropIndexesFromCollection(db.docs, DOCS_INDEXES)
|
|
|
|
await Helpers.dropIndexesFromCollection(db.tags, TAGS_INDEXES)
|
|
|
|
await Helpers.dropIndexesFromCollection(db.projects, PROJECTS_INDEXES)
|
|
|
|
}
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const rollback = async ({ db }) => {
|
2023-11-02 08:47:39 -04:00
|
|
|
await Helpers.addIndexesToCollection(db.docs, DOCS_INDEXES)
|
|
|
|
await Helpers.addIndexesToCollection(db.tags, TAGS_INDEXES)
|
|
|
|
await Helpers.addIndexesToCollection(db.projects, PROJECTS_INDEXES)
|
|
|
|
}
|
2024-10-02 05:32:13 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
tags,
|
|
|
|
migrate,
|
|
|
|
rollback,
|
|
|
|
}
|