tango-core 0.3.0

The tango schema, entities, migrations, and search contract
Documentation
use sea_orm_migration::prelude::*;

/// Makes v3 harvests resumable.
///
/// Each page of the uploads playlist commits on its own and records where to
/// resume, so a run that stops on exhausted quota continues from where it
/// left off instead of re-fetching pages it already wrote.
#[derive(DeriveMigrationName)]
pub struct Migration;

const UP: &str = include_str!("sql/0004_resumable_harvests.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 marking function is dropped too, so a revert leaves no orphans
        // that reference a column the next `up` will recreate.
        manager
            .get_connection()
            .execute_unprepared(
                r#"
                DROP FUNCTION IF EXISTS public.mark_videos_as_shorts(text[]);
                ALTER TABLE public.channels DROP COLUMN IF EXISTS harvest_page_token;
                "#,
            )
            .await?;
        Ok(())
    }
}