Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/server/models/LivechatRooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class LivechatRooms extends Base {
this.tryEnsureIndex({ 'omnichannel.predictedVisitorAbandonmentAt': 1 }, { sparse: true });
this.tryEnsureIndex({ closedAt: 1 }, { sparse: true });
this.tryEnsureIndex({ servedBy: 1 }, { sparse: true });
this.tryEnsureIndex({ 'v.token': 1 }, { sparse: true });
}

findLivechat(filter = {}, offset = 0, limit = 20) {
Expand Down
3 changes: 3 additions & 0 deletions app/models/server/models/LivechatVisitors.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import Settings from './Settings';
export class LivechatVisitors extends Base {
constructor() {
super('livechat_visitor');

this.tryEnsureIndex({ token: 1 });
this.tryEnsureIndex({ 'phone.phoneNumber': 1 }, { sparse: true });
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/models/server/models/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class Messages extends Base {
constructor() {
super('message');

this.tryEnsureIndex({ rid: 1, ts: 1 });
this.tryEnsureIndex({ rid: 1, ts: 1, _updatedAt: 1 });
this.tryEnsureIndex({ ts: 1 });
this.tryEnsureIndex({ 'u._id': 1 });
this.tryEnsureIndex({ editedAt: 1 }, { sparse: true });
Expand Down
9 changes: 6 additions & 3 deletions app/models/server/models/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ export class Rooms extends Base {
super(...args);

this.tryEnsureIndex({ name: 1 }, { unique: true, sparse: true });
this.tryEnsureIndex({ default: 1 });
this.tryEnsureIndex({ featured: 1 });
this.tryEnsureIndex({ default: 1 }, { sparse: true });
this.tryEnsureIndex({ featured: 1 }, { sparse: true });
this.tryEnsureIndex({ muted: 1 }, { sparse: true });
this.tryEnsureIndex({ t: 1 });
this.tryEnsureIndex({ 'u._id': 1 });
this.tryEnsureIndex({ 'tokenpass.tokens.token': 1 });
this.tryEnsureIndex({ ts: 1 });
// Tokenpass
this.tryEnsureIndex({ 'tokenpass.tokens.token': 1 }, { sparse: true });
this.tryEnsureIndex({ tokenpass: 1 }, { sparse: true });
// discussions
this.tryEnsureIndex({ prid: 1 }, { sparse: true });
this.tryEnsureIndex({ fname: 1 }, { sparse: true });
Expand Down
1 change: 1 addition & 0 deletions app/models/server/models/Sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ export class Sessions extends Base {
this.tryEnsureIndex({ instanceId: 1, sessionId: 1, year: 1, month: 1, day: 1 });
this.tryEnsureIndex({ instanceId: 1, sessionId: 1, userId: 1 });
this.tryEnsureIndex({ instanceId: 1, sessionId: 1 });
this.tryEnsureIndex({ sessionId: 1 });
this.tryEnsureIndex({ year: 1, month: 1, day: 1, type: 1 });
this.tryEnsureIndex({ type: 1 });
this.tryEnsureIndex({ _computedAt: 1 }, { expireAfterSeconds: 60 * 60 * 24 * 45 });
Expand Down
1 change: 1 addition & 0 deletions app/models/server/models/Subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class Subscriptions extends Base {
this.tryEnsureIndex({ rid: 1, alert: 1, 'u._id': 1 });
this.tryEnsureIndex({ rid: 1, roles: 1 });
this.tryEnsureIndex({ 'u._id': 1, name: 1, t: 1 });
this.tryEnsureIndex({ name: 1, t: 1 });
this.tryEnsureIndex({ open: 1 });
this.tryEnsureIndex({ alert: 1 });
this.tryEnsureIndex({ ts: 1 });
Expand Down
6 changes: 4 additions & 2 deletions app/models/server/models/_BaseDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import { getMongoInfo } from '../../../utils/server/functions/getMongoInfo';

const baseName = 'rocketchat_';

const trash = new Mongo.Collection(`${ baseName }_trash`);
export const trash = new Mongo.Collection(`${ baseName }_trash`);
try {
trash._ensureIndex({ collection: 1 });
trash._ensureIndex({ __collection__: 1 });
trash._ensureIndex(
{ _deletedAt: 1 },
{ expireAfterSeconds: 60 * 60 * 24 * 30 },
);

trash._ensureIndex({ rid: 1, __collection__: 1, _deletedAt: 1 });
} catch (e) {
console.log(e);
}
Expand Down
1 change: 1 addition & 0 deletions server/startup/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,5 @@ import './v188';
import './v189';
import './v190';
import './v191';
import './v192';
import './xrun';
28 changes: 28 additions & 0 deletions server/startup/migrations/v192.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Migrations } from '../../../app/migrations/server';
import { Messages, Rooms } from '../../../app/models/server';
import { trash } from '../../../app/models/server/models/_BaseDb';

Migrations.add({
version: 192,
up() {
try {
trash._dropIndex({ collection: 1 });
} catch {
//
}

Messages.tryDropIndex({ rid: 1, ts: 1 });

Rooms.tryDropIndex({ 'tokenpass.tokens.token': 1 });
Rooms.tryEnsureIndex({ 'tokenpass.tokens.token': 1 }, { sparse: true });

Rooms.tryDropIndex({ default: 1 });
Rooms.tryEnsureIndex({ default: 1 }, { sparse: true });

Rooms.tryDropIndex({ featured: 1 });
Rooms.tryEnsureIndex({ featured: 1 }, { sparse: true });

Rooms.tryDropIndex({ muted: 1 });
Rooms.tryEnsureIndex({ muted: 1 }, { sparse: true });
},
});