Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
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
11 changes: 8 additions & 3 deletions app/models/server/models/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ 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 });
// livechat
this.tryEnsureIndex({ 'v.token': 1 }, { sparse: true });
Comment thread
rodrigok marked this conversation as resolved.
Outdated
// 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
4 changes: 3 additions & 1 deletion app/models/server/models/_BaseDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ const baseName = 'rocketchat_';

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({ __collection__: 1, _deletedAt: 1, rid: 1 });
Comment thread
rodrigok marked this conversation as resolved.
Outdated
} catch (e) {
console.log(e);
}
Expand Down