From b0344ec550a98bbe8156cd8dd9d072dc3c10d909 Mon Sep 17 00:00:00 2001 From: Jimmy Domagala-Tang Date: Tue, 25 Jun 2024 11:28:10 -0400 Subject: [PATCH] Merge pull request #19132 from overleaf/jdt-ai-policy-migration feat: add migration for adding new policy to all existing groupPolicies GitOrigin-RevId: ea3188b6059c2e96afd0058a191d18b26d68adbd --- services/web/app/src/infrastructure/mongodb.js | 1 + ...40625101055_add_ai_policy_to_group_policy.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 services/web/migrations/20240625101055_add_ai_policy_to_group_policy.js diff --git a/services/web/app/src/infrastructure/mongodb.js b/services/web/app/src/infrastructure/mongodb.js index f14d5595f4..ada77c4380 100644 --- a/services/web/app/src/infrastructure/mongodb.js +++ b/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') diff --git a/services/web/migrations/20240625101055_add_ai_policy_to_group_policy.js b/services/web/migrations/20240625101055_add_ai_policy_to_group_policy.js new file mode 100644 index 0000000000..a9027cfd20 --- /dev/null +++ b/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: '' } } + ) +}