From 62cdd76443bbecfbdb70a82a7936a2e602338692 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 22 Feb 2025 11:38:08 +0100 Subject: fix(yt/storage/migrate/sql/01_zero_to_one.sql): Account for duration being NULL --- yt/src/storage/migrate/sql/01_zero_to_one.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/yt/src/storage/migrate/sql/01_zero_to_one.sql b/yt/src/storage/migrate/sql/01_zero_to_one.sql index 42c3b02..d33eb05 100644 --- a/yt/src/storage/migrate/sql/01_zero_to_one.sql +++ b/yt/src/storage/migrate/sql/01_zero_to_one.sql @@ -11,9 +11,8 @@ UPDATE videos SET is_focused = 0; -- The progress the user made in watching the video. ALTER TABLE videos ADD watch_progress INTEGER NOT NULL DEFAULT 0 CHECK (watch_progress <= duration); - -- Assume, that the user has watched the video to end, if it is marked as watched -UPDATE videos SET watch_progress = duration WHERE status = 3; +UPDATE videos SET watch_progress = ifnull(duration, 0) WHERE status = 3; UPDATE videos SET watch_progress = 0 WHERE status != 3; ALTER TABLE videos DROP COLUMN status_change; -- cgit 1.4.1