2024-10-02 05:32:13 -04:00
|
|
|
import Helpers from './lib/helpers.mjs'
|
2023-04-10 09:56:37 -04:00
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const tags = ['server-ce', 'server-pro', 'saas']
|
2023-04-10 09:56:37 -04:00
|
|
|
|
|
|
|
const ACCESS_TOKENS_INDEX = {
|
|
|
|
name: 'expiresAt_1',
|
|
|
|
key: { expiresAt: 1 },
|
|
|
|
partialFilterExpression: { expiresAt: { $exists: true } },
|
|
|
|
expireAfterSeconds: 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
const AUTHORIZATION_CODES_INDEX = {
|
|
|
|
name: 'expiresAt_1',
|
|
|
|
key: { expiresAt: 1 },
|
|
|
|
partialFilterExpression: { expiresAt: { $exists: true } },
|
|
|
|
expireAfterSeconds: 0,
|
|
|
|
}
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const migrate = async ({ db }) => {
|
2023-04-10 09:56:37 -04:00
|
|
|
await Helpers.addIndexesToCollection(db.oauthAccessTokens, [
|
|
|
|
ACCESS_TOKENS_INDEX,
|
|
|
|
])
|
|
|
|
await Helpers.addIndexesToCollection(db.oauthAuthorizationCodes, [
|
|
|
|
AUTHORIZATION_CODES_INDEX,
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const rollback = async ({ db }) => {
|
2023-04-10 09:56:37 -04:00
|
|
|
await Helpers.dropIndexesFromCollection(db.oauthAccessTokens, [
|
|
|
|
ACCESS_TOKENS_INDEX,
|
|
|
|
])
|
|
|
|
await Helpers.dropIndexesFromCollection(db.oauthAuthorizationCodes, [
|
|
|
|
AUTHORIZATION_CODES_INDEX,
|
|
|
|
])
|
|
|
|
}
|
2024-10-02 05:32:13 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
tags,
|
|
|
|
migrate,
|
|
|
|
rollback,
|
|
|
|
}
|