2024-10-02 05:32:13 -04:00
|
|
|
import Helpers from './lib/helpers.mjs'
|
2023-11-02 08:47:27 -04:00
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const tags = ['server-ce', 'server-pro', 'saas']
|
2023-11-02 08:47:27 -04:00
|
|
|
|
|
|
|
const OLD_INDEX = {
|
|
|
|
name: 'active_1_lastOpened_1',
|
|
|
|
key: { active: 1, lastOpened: 1 },
|
|
|
|
}
|
|
|
|
|
|
|
|
const NEW_INDEX = {
|
|
|
|
name: 'lastOpened_1',
|
|
|
|
key: { lastOpened: 1 },
|
|
|
|
partialFilterExpression: { active: true },
|
|
|
|
}
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const migrate = async client => {
|
2023-11-02 08:47:27 -04:00
|
|
|
const { db } = client
|
|
|
|
await Helpers.addIndexesToCollection(db.projects, [NEW_INDEX])
|
|
|
|
await Helpers.dropIndexesFromCollection(db.projects, [OLD_INDEX])
|
|
|
|
}
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const rollback = async client => {
|
2023-11-02 08:47:27 -04:00
|
|
|
const { db } = client
|
|
|
|
await Helpers.addIndexesToCollection(db.projects, [OLD_INDEX])
|
|
|
|
await Helpers.dropIndexesFromCollection(db.projects, [NEW_INDEX])
|
|
|
|
}
|
2024-10-02 05:32:13 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
tags,
|
|
|
|
migrate,
|
|
|
|
rollback,
|
|
|
|
}
|