Преглед изворни кода

Merge pull request #19132 from overleaf/jdt-ai-policy-migration

feat: add migration for adding new policy to all existing groupPolicies
GitOrigin-RevId: ea3188b6059c2e96afd0058a191d18b26d68adbd
Jimmy Domagala-Tang пре 2 година
родитељ
комит
b0344ec550

+ 1 - 0
services/web/app/src/infrastructure/mongodb.js

@@ -61,6 +61,7 @@ async function setupDb() {
   db.githubSyncUserCredentials = internalDb.collection(
     'githubSyncUserCredentials'
   )
+  db.grouppolicies = internalDb.collection('grouppolicies')
   db.institutions = internalDb.collection('institutions')
   db.messages = internalDb.collection('messages')
   db.migrations = internalDb.collection('migrations')

+ 17 - 0
services/web/migrations/20240625101055_add_ai_policy_to_group_policy.js

@@ -0,0 +1,17 @@
+exports.tags = ['saas']
+
+exports.migrate = async client => {
+  const { db } = client
+  await db.grouppolicies.updateMany(
+    {},
+    { $set: { userCannotUseAIFeatures: true } }
+  )
+}
+
+exports.rollback = async client => {
+  const { db } = client
+  await db.grouppolicies.updateMany(
+    {},
+    { $unset: { userCannotUseAIFeatures: '' } }
+  )
+}