1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use sea_orm_migration::prelude::*;
/// Documents the download URLs now stored alongside caption availability.
///
/// Comment-only. The column is jsonb, so widening its shape needs no DDL and no
/// backfill, and `#[serde(default)]` reads a row written under the older shape
/// as an empty list rather than failing — which is what lets the transcript
/// command fall back to rediscovery instead of erroring on stored rows.
///
/// The point of storing them: a transcript pass makes one yt-dlp call per video
/// rather than two. The yt-dlp payload already carries a signed `timedtext`
/// URL for every WebVTT track, so the download is a plain GET — measured at
/// ~700ms against ~15s for a yt-dlp fetch, which re-extracts the YouTube
/// webpage to find a URL the payload already contained.
#[derive(DeriveMigrationName)]
pub struct Migration;
const UP: &str = include_str!("sql/0010_availability_track_urls.sql");
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager.get_connection().execute_unprepared(UP).await?;
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
// The data is untouched by this migration, so there is nothing to
// reverse. The older comment is restored rather than left wrong, though
// only the up direction is ever used in practice.
manager
.get_connection()
.execute_unprepared(
r#"
COMMENT ON COLUMN public.videos.subtitle_availability IS
'Caption tracks the yt-dlp backend saw, as {"manual_langs": [...], "auto_langs": [...]}.
NULL means unknown, not none: the v3 backend cannot see caption tracks, so a
v3-only harvest leaves this NULL. Machine translations (tlang) are excluded
by inspect_subtitles and never appear here.';
"#,
)
.await?;
Ok(())
}
}