Drop calls from migration with the same callId and peerId
This commit is contained in:
parent
1eaabb6734
commit
e20fa41fd5
2 changed files with 89 additions and 0 deletions
|
@ -77,6 +77,8 @@ export default function updateToSchemaVersion87(
|
|||
|
||||
const rows = db.prepare(selectQuery).all();
|
||||
|
||||
const uniqueConstraint = new Set();
|
||||
|
||||
for (const row of rows) {
|
||||
const json = JSON.parse(row.json);
|
||||
const details = json.callHistoryDetails;
|
||||
|
@ -153,6 +155,17 @@ export default function updateToSchemaVersion87(
|
|||
continue;
|
||||
}
|
||||
|
||||
// We need to ensure a call with the same callId and peerId doesn't get
|
||||
// inserted twice because of the unique constraint on the table.
|
||||
const uniqueKey = `${callId} -> ${peerId}`;
|
||||
if (uniqueConstraint.has(uniqueKey)) {
|
||||
logger.error(
|
||||
`updateToSchemaVersion87: duplicate callId/peerId pair (${uniqueKey})`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
uniqueConstraint.add(uniqueKey);
|
||||
|
||||
const [insertQuery, insertParams] = sql`
|
||||
INSERT INTO callsHistory (
|
||||
callId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue