diff --git a/services/web/app/src/infrastructure/mongodb.js b/services/web/app/src/infrastructure/mongodb.js index 124d109e39..1912584980 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.oauthApplications = internalDb.collection('oauthApplications') db.oauthAuthorizationCodes = internalDb.collection('oauthAuthorizationCodes') db.projectAuditLogEntries = internalDb.collection('projectAuditLogEntries') + db.projectHistoryChunks = internalDb.collection('projectHistoryChunks') db.projectHistoryFailures = internalDb.collection('projectHistoryFailures') db.projectHistoryLabels = internalDb.collection('projectHistoryLabels') db.projectHistoryMetaData = internalDb.collection('projectHistoryMetaData') diff --git a/services/web/migrations/20221122191857_project_history_chunks_indexes.js b/services/web/migrations/20221122191857_project_history_chunks_indexes.js new file mode 100644 index 0000000000..d4528a0f51 --- /dev/null +++ b/services/web/migrations/20221122191857_project_history_chunks_indexes.js @@ -0,0 +1,27 @@ +/* eslint-disable no-unused-vars */ + +const Helpers = require('./lib/helpers') + +exports.tags = ['server-ce', 'server-pro', 'saas'] + +const indexes = [ + { + key: { projectId: 1, startVersion: 1 }, + name: 'projectId_1_startVersion_1', + partialFilterExpression: { state: 'active' }, + unique: true, + }, + { + key: { state: 1 }, + name: 'state_1', + partialFilterExpression: { state: 'deleted' }, + }, +] + +exports.migrate = async ({ db }) => { + await Helpers.addIndexesToCollection(db.projectHistoryChunks, indexes) +} + +exports.rollback = async ({ db }) => { + await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, indexes) +}