Disable part of the migration 58
This commit is contained in:
parent
a114e4e210
commit
e86a312b74
2 changed files with 11 additions and 83 deletions
|
@ -21,13 +21,17 @@ export default function updateToSchemaVersion58(
|
|||
`
|
||||
--- Promote unread status in JSON to SQL column
|
||||
|
||||
UPDATE messages
|
||||
SET
|
||||
readStatus = ${ReadStatus.Unread},
|
||||
seenStatus = ${SeenStatus.Unseen}
|
||||
WHERE
|
||||
json_extract(json, '$.unread') IS true OR
|
||||
json_extract(json, '$.unread') IS 1;
|
||||
-- NOTE: This was disabled because the 'unread' json field was deprecated
|
||||
-- in b0750e5f4e1f79f0f177b17cbe06d688431f948d, but the old value was kept
|
||||
-- in the messages created before the release of that commit.
|
||||
--
|
||||
-- UPDATE messages
|
||||
-- SET
|
||||
-- readStatus = ${ReadStatus.Unread},
|
||||
-- seenStatus = ${SeenStatus.Unseen}
|
||||
-- WHERE
|
||||
-- json_extract(json, '$.unread') IS true OR
|
||||
-- json_extract(json, '$.unread') IS 1;
|
||||
|
||||
--- Clean up all old messages that still have a null read status
|
||||
--- Note: we don't need to update seenStatus, because that was defaulted to zero
|
||||
|
|
|
@ -2028,82 +2028,6 @@ describe('SQL migrations test', () => {
|
|||
});
|
||||
|
||||
describe('updateToSchemaVersion58', () => {
|
||||
it('updates readStatus/seenStatus for messages with unread: true/1 in JSON', () => {
|
||||
const MESSAGE_ID_1 = generateGuid();
|
||||
const MESSAGE_ID_2 = generateGuid();
|
||||
const MESSAGE_ID_3 = generateGuid();
|
||||
const MESSAGE_ID_4 = generateGuid();
|
||||
const CONVERSATION_ID = generateGuid();
|
||||
|
||||
updateToVersion(57);
|
||||
|
||||
// prettier-ignore
|
||||
db.exec(
|
||||
`
|
||||
INSERT INTO messages
|
||||
(id, conversationId, type, json)
|
||||
VALUES
|
||||
('${MESSAGE_ID_1}', '${CONVERSATION_ID}', 'incoming', '${JSON.stringify(
|
||||
{ unread: true }
|
||||
)}'),
|
||||
('${MESSAGE_ID_2}', '${CONVERSATION_ID}', 'incoming', '${JSON.stringify(
|
||||
{ unread: 1 }
|
||||
)}'),
|
||||
('${MESSAGE_ID_3}', '${CONVERSATION_ID}', 'incoming', '${JSON.stringify(
|
||||
{ unread: undefined }
|
||||
)}'),
|
||||
('${MESSAGE_ID_4}', '${CONVERSATION_ID}', 'incoming', '${JSON.stringify(
|
||||
{ unread: 0 }
|
||||
)}');
|
||||
`
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
db.prepare('SELECT COUNT(*) FROM messages;').pluck().get(),
|
||||
4,
|
||||
'starting total'
|
||||
);
|
||||
|
||||
updateToVersion(58);
|
||||
|
||||
assert.strictEqual(
|
||||
db.prepare('SELECT COUNT(*) FROM messages;').pluck().get(),
|
||||
4,
|
||||
'ending total'
|
||||
);
|
||||
assert.strictEqual(
|
||||
db
|
||||
.prepare(
|
||||
`SELECT COUNT(*) FROM messages WHERE readStatus = ${ReadStatus.Unread};`
|
||||
)
|
||||
.pluck()
|
||||
.get(),
|
||||
2,
|
||||
'ending unread count'
|
||||
);
|
||||
assert.strictEqual(
|
||||
db
|
||||
.prepare(
|
||||
`SELECT COUNT(*) FROM messages WHERE seenStatus = ${SeenStatus.Unseen};`
|
||||
)
|
||||
.pluck()
|
||||
.get(),
|
||||
2,
|
||||
'ending unread count'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
db
|
||||
.prepare(
|
||||
`SELECT readStatus FROM messages WHERE id = '${MESSAGE_ID_2}' LIMIT 1;`
|
||||
)
|
||||
.pluck()
|
||||
.get(),
|
||||
ReadStatus.Unread,
|
||||
'checking read status for message2'
|
||||
);
|
||||
});
|
||||
|
||||
it('updates unseenStatus for previously-unread messages', () => {
|
||||
const MESSAGE_ID_1 = generateGuid();
|
||||
const MESSAGE_ID_2 = generateGuid();
|
||||
|
|
Loading…
Add table
Reference in a new issue