Skip to content

Commit

Permalink
dont fail on already existing indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
pofider committed Jan 15, 2024
1 parent 00be95e commit f417ccb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ module.exports = function (reporter, definition) {
if (reporter.options.store.provider === 'mongodb') {
reporter.logger.debug('Creating workspace indexes')
await Promise.all([
reporter.documentStore.provider.db.collection('workspaces').createIndex({ name: 'text', description: 'text' }),
reporter.documentStore.provider.db.collection('workspaces').createIndex({ userId: 1 }),
reporter.documentStore.provider.db.collection('workspaces').createIndex({ views: -1 })
reporter.documentStore.provider.db.collection('workspaces').createIndex({ name: 'text', description: 'text' }).catch(() => {}),
reporter.documentStore.provider.db.collection('workspaces').createIndex({ userId: 1 }).catch(() => {}),
reporter.documentStore.provider.db.collection('workspaces').createIndex({ views: -1 }).catch(() => {})
])

reporter.logger.debug('Creating entities indexes')
const entities = ['assets', 'data', 'scripts', 'templates', 'profiles', 'components', 'versions', 'folders', 'tags']
await Promise.all(entities.map((c) => reporter.documentStore.provider.db.collection(c).createIndex({ workspaceId: 1 })))
await Promise.all(entities.map((c) => reporter.documentStore.provider.db.collection(c).createIndex({ workspaceId: 1 }).catch(() => {})))
}

reporter.documentStore.internalCollection('workspaces').beforeInsertListeners.add('playground', (doc) => {
Expand Down

0 comments on commit f417ccb

Please sign in to comment.