Extra logging for GV2 UUID migration
This commit is contained in:
parent
5bd7eda124
commit
7f9beef055
2 changed files with 13 additions and 5 deletions
|
@ -37,6 +37,7 @@ export default function updateToSchemaVersion43(
|
||||||
|
|
||||||
type LegacyConversationType = {
|
type LegacyConversationType = {
|
||||||
id: string;
|
id: string;
|
||||||
|
groupId: string;
|
||||||
membersV2?: Array<{
|
membersV2?: Array<{
|
||||||
conversationId: string;
|
conversationId: string;
|
||||||
}>;
|
}>;
|
||||||
|
@ -78,6 +79,8 @@ export default function updateToSchemaVersion43(
|
||||||
const legacy = (convo as unknown) as LegacyConversationType;
|
const legacy = (convo as unknown) as LegacyConversationType;
|
||||||
let result = convo;
|
let result = convo;
|
||||||
|
|
||||||
|
const logId = `(${legacy.id}) groupv2(${legacy.groupId})`;
|
||||||
|
|
||||||
const memberKeys: Array<keyof LegacyConversationType> = [
|
const memberKeys: Array<keyof LegacyConversationType> = [
|
||||||
'membersV2',
|
'membersV2',
|
||||||
'pendingMembersV2',
|
'pendingMembersV2',
|
||||||
|
@ -98,7 +101,7 @@ export default function updateToSchemaVersion43(
|
||||||
});
|
});
|
||||||
if (!uuid) {
|
if (!uuid) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`updateToSchemaVersion43: ${legacy.id}.${key} UUID not found ` +
|
`updateToSchemaVersion43: ${logId}.${key} UUID not found ` +
|
||||||
`for ${member.conversationId}`
|
`for ${member.conversationId}`
|
||||||
);
|
);
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -141,14 +144,14 @@ export default function updateToSchemaVersion43(
|
||||||
if (oldValue.length !== 0) {
|
if (oldValue.length !== 0) {
|
||||||
logger.info(
|
logger.info(
|
||||||
`updateToSchemaVersion43: migrated ${oldValue.length} ${key} ` +
|
`updateToSchemaVersion43: migrated ${oldValue.length} ${key} ` +
|
||||||
`entries to ${newValue.length} for ${legacy.id}`
|
`entries to ${newValue.length} for ${logId}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addedByCount > 0) {
|
if (addedByCount > 0) {
|
||||||
logger.info(
|
logger.info(
|
||||||
`updateToSchemaVersion43: migrated ${addedByCount} addedByUserId ` +
|
`updateToSchemaVersion43: migrated ${addedByCount} addedByUserId ` +
|
||||||
`in ${key} for ${legacy.id}`
|
`in ${key} for ${logId}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -626,8 +626,12 @@ describe('SQL migrations test', () => {
|
||||||
const UUID_B = generateGuid();
|
const UUID_B = generateGuid();
|
||||||
const UUID_C = generateGuid();
|
const UUID_C = generateGuid();
|
||||||
|
|
||||||
|
const rawConvoA = { id: 'a', groupId: 'gv2a', uuid: UUID_A };
|
||||||
|
const rawConvoB = { id: 'b', groupId: 'gv2b', uuid: UUID_B };
|
||||||
|
|
||||||
const rawConvoC = {
|
const rawConvoC = {
|
||||||
id: 'c',
|
id: 'c',
|
||||||
|
groupId: 'gv2c',
|
||||||
uuid: UUID_C,
|
uuid: UUID_C,
|
||||||
membersV2: [
|
membersV2: [
|
||||||
{ conversationId: 'a', joinedAtVersion: 1 },
|
{ conversationId: 'a', joinedAtVersion: 1 },
|
||||||
|
@ -668,8 +672,8 @@ describe('SQL migrations test', () => {
|
||||||
INSERT INTO conversations
|
INSERT INTO conversations
|
||||||
(id, uuid, json)
|
(id, uuid, json)
|
||||||
VALUES
|
VALUES
|
||||||
('a', '${UUID_A}', '${JSON.stringify({ id: 'a', uuid: UUID_A })}'),
|
('a', '${UUID_A}', '${JSON.stringify(rawConvoA)}'),
|
||||||
('b', '${UUID_B}', '${JSON.stringify({ id: 'b', uuid: UUID_B })}'),
|
('b', '${UUID_B}', '${JSON.stringify(rawConvoB)}'),
|
||||||
('c', '${UUID_C}', '${JSON.stringify(rawConvoC)}');
|
('c', '${UUID_C}', '${JSON.stringify(rawConvoC)}');
|
||||||
|
|
||||||
INSERT INTO messages
|
INSERT INTO messages
|
||||||
|
@ -714,6 +718,7 @@ describe('SQL migrations test', () => {
|
||||||
assert.strictEqual(members, `${UUID_A} ${UUID_B}`);
|
assert.strictEqual(members, `${UUID_A} ${UUID_B}`);
|
||||||
assert.deepStrictEqual(JSON.parse(convoJSON), {
|
assert.deepStrictEqual(JSON.parse(convoJSON), {
|
||||||
id: 'c',
|
id: 'c',
|
||||||
|
groupId: 'gv2c',
|
||||||
uuid: UUID_C,
|
uuid: UUID_C,
|
||||||
membersV2: [
|
membersV2: [
|
||||||
{ uuid: UUID_A, joinedAtVersion: 1 },
|
{ uuid: UUID_A, joinedAtVersion: 1 },
|
||||||
|
|
Loading…
Reference in a new issue