Anki/rslib/src/storage/revlog/fix_props.sql
Damien Elmes 28ba578fc7 Fix invalid reschedule revlog entries
https://forums.ankiweb.net/t/statistics-messed-up-after-fsrs-reschedule/54622

Caused by syncing the revlogs in a normal sync to a client that doesn't
understand them yet - they end up using the default for RevlogReviewKind
instead, which is 0.
2025-01-24 19:06:50 +11:00

23 lines
No EOL
585 B
SQL

UPDATE revlog
SET ivl = min(max(round(ivl), -2147483648), 2147483647),
lastIvl = min(max(round(lastIvl), -2147483648), 2147483647),
time = min(max(round(time), 0), 2147483647),
type = (
CASE
WHEN type = 0
AND time = 0
AND ease = 0 THEN 5
ELSE type
END
)
WHERE ivl != min(max(round(ivl), -2147483648), 2147483647)
OR lastIvl != min(max(round(lastIvl), -2147483648), 2147483647)
OR time != min(max(round(time), 0), 2147483647)
OR type != (
CASE
WHEN type = 0
AND time = 0
AND ease = 0 THEN 5
ELSE type
END
)