diff --git a/app/models/server/models/apps-persistence-model.js b/app/models/server/models/apps-persistence-model.js index da178a390c327..dd01197abbc94 100644 --- a/app/models/server/models/apps-persistence-model.js +++ b/app/models/server/models/apps-persistence-model.js @@ -4,7 +4,7 @@ export class AppsPersistenceModel extends Base { constructor() { super('apps_persistence'); - this.tryEnsureIndex({ appId: 1 }); + this.tryEnsureIndex({ appId: 1, associations: 1 }); } // Bypass trash collection diff --git a/server/startup/migrations/index.ts b/server/startup/migrations/index.ts index 319024966076c..7b7ccf8282baa 100644 --- a/server/startup/migrations/index.ts +++ b/server/startup/migrations/index.ts @@ -71,4 +71,5 @@ import './v244'; import './v245'; import './v246'; import './v247'; +import './v248'; import './xrun'; diff --git a/server/startup/migrations/v248.ts b/server/startup/migrations/v248.ts new file mode 100644 index 0000000000000..d8670ecd540c2 --- /dev/null +++ b/server/startup/migrations/v248.ts @@ -0,0 +1,12 @@ +import { addMigration } from '../../lib/migrations'; +import { Apps } from '../../../app/apps/server/orchestrator'; + +addMigration({ + version: 248, + up() { + // we now have a compound index on appId + associations + // so we can use the index prefix instead of a separate index on appId + Apps.initialize(); + return Apps._persistModel?.tryDropIndex({ appId: 1 }); + }, +});