2024-10-01 05:53:36 -04:00
|
|
|
const Helpers = require('./lib/helpers')
|
2023-04-10 09:56:37 -04:00
|
|
|
|
2024-10-01 05:53:36 -04:00
|
|
|
exports.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-01 05:53:36 -04:00
|
|
|
exports.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-01 05:53:36 -04:00
|
|
|
exports.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,
|
|
|
|
])
|
|
|
|
}
|