Skip to content
Open
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
1 change: 1 addition & 0 deletions apps/meteor/server/startup/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ import './v332';
import './v333';
import './v334';
import './v335';
import './v336';

export * from './xrun';
30 changes: 30 additions & 0 deletions apps/meteor/server/startup/migrations/v336.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { addMigration } from '../../lib/migrations';
import { ReadReceipts } from '@rocket.chat/models';

addMigration({
version: 336,
name: 'Drop legacy unique index from read_receipts',

async up() {
const collection = ReadReceipts.col;

const indexes = await collection.indexes();

const matchingIndexes = indexes.filter((idx) => {
const keys = idx.key || {};

return (
Object.keys(keys).length === 3 &&
keys.roomId === 1 &&
keys.userId === 1 &&
keys.messageId === 1
);
});

for (const idx of matchingIndexes) {
if (idx.name) {
await collection.dropIndex(idx.name);
}
}
},
});