diff --git a/services/web/migrations/20250728103841_group_audit_log_expire_index.mjs b/services/web/migrations/20250728103841_group_audit_log_expire_index.mjs new file mode 100644 index 0000000000..089b1343fb --- /dev/null +++ b/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, +}