overleaf/services/web/migrations/20231025094810_sso_config_certificates_array.js
Alexandre Bourdin c71301ac9a Merge pull request #15223 from overleaf/ab-sso-multiple-certificates-ui
[web] Support multiple certificates in group SSO settings

GitOrigin-RevId: 5f014eb82b7e0820040941fdd2bded8d33958316
2023-10-30 09:04:38 +00:00

35 lines
869 B
JavaScript

exports.tags = ['saas']
exports.migrate = async client => {
const { db } = client
await db.ssoConfigs.updateMany(
{ certificate: { $exists: true }, certificates: { $exists: false } },
[
{ $set: { certificates: ['$certificate'] } },
{
$unset: 'certificate',
},
]
)
await db.ssoConfigs.updateMany(
{ userFirstNameAttribute: null },
{ $unset: { userFirstNameAttribute: true } }
)
await db.ssoConfigs.updateMany(
{ userLastNameAttribute: null },
{ $unset: { userLastNameAttribute: true } }
)
}
exports.rollback = async client => {
const { db } = client
await db.ssoConfigs.updateMany(
{ certificate: { $exists: false }, certificates: { $exists: true } },
[
{ $set: { certificate: { $arrayElemAt: ['$certificates', 0] } } },
{
$unset: 'certificates',
},
]
)
}