瀏覽代碼

[web] Add expiration for `groupAuditLogEntries` collection (#27437)

Set to 2.5 years, same as user/project audit logs

GitOrigin-RevId: d3b7e6d752eda4b224068e7b37276e79b4143464
Miguel Serrano 1 年之前
父節點
當前提交
e2e6c6a7f3
共有 1 個文件被更改,包括 32 次插入 和 0 次删除
  1. 32 0
      services/web/migrations/20250728103841_group_audit_log_expire_index.mjs

+ 32 - 0
services/web/migrations/20250728103841_group_audit_log_expire_index.mjs

@@ -0,0 +1,32 @@
+import Helpers from './lib/helpers.mjs'
+
+const tags = ['saas']
+
+const indexes = [
+  {
+    // expire after 2.5 years
+    expireAfterSeconds: 60 * 60 * 24 * 365 * 2.5,
+    key: {
+      timestamp: 1,
+    },
+    name: 'timestamp_1',
+  },
+]
+
+const migrate = async client => {
+  const { db } = client
+  await Helpers.addIndexesToCollection(db.groupAuditLogEntries, indexes)
+}
+
+const rollback = async client => {
+  const { db } = client
+  await Promise.all([
+    Helpers.dropIndexesFromCollection(db.groupAuditLogEntries, indexes),
+  ])
+}
+
+export default {
+  tags,
+  migrate,
+  rollback,
+}