2024-10-02 05:32:13 -04:00
|
|
|
import Helpers from './lib/helpers.mjs'
|
2022-09-29 13:58:00 -04:00
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const tags = ['server-ce', 'server-pro', 'saas']
|
2022-09-29 13:58:00 -04:00
|
|
|
|
|
|
|
const projectIndexes = [
|
|
|
|
{
|
|
|
|
key: {
|
|
|
|
projectId: 1,
|
|
|
|
},
|
|
|
|
name: 'project_id_1',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
const userIndexes = [
|
|
|
|
{
|
|
|
|
key: {
|
|
|
|
userId: 1,
|
|
|
|
},
|
|
|
|
name: 'user_id_1',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const migrate = async client => {
|
2022-09-29 13:58:00 -04:00
|
|
|
const { db } = client
|
|
|
|
await Helpers.addIndexesToCollection(
|
|
|
|
db.projectAuditLogEntries,
|
|
|
|
projectIndexes
|
|
|
|
)
|
|
|
|
await Helpers.addIndexesToCollection(db.userAuditLogEntries, userIndexes)
|
|
|
|
}
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const rollback = async client => {
|
2022-09-29 13:58:00 -04:00
|
|
|
const { db } = client
|
|
|
|
await Promise.all([
|
|
|
|
Helpers.dropIndexesFromCollection(
|
|
|
|
db.projectAuditLogEntries,
|
|
|
|
projectIndexes
|
|
|
|
),
|
|
|
|
Helpers.dropIndexesFromCollection(db.userAuditLogEntries, userIndexes),
|
|
|
|
])
|
|
|
|
}
|
2024-10-02 05:32:13 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
tags,
|
|
|
|
migrate,
|
|
|
|
rollback,
|
|
|
|
}
|