tango-core 0.3.0

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

/// Splits transcript search out of the unified search, and into the database.
///
/// `/search` matched titles, descriptions, tags *and* transcript bodies; the
/// transcript tier was reachable by accident through `in=transcript`, so whether
/// a query could find a video by what was said in it depended on which videos
/// happened to have been fetched. It also ranked its seek position differently
/// from `/transcripts/search`, so the two endpoints could disagree about where
/// in a video a phrase was mentioned.
///
/// `search_all_hits` loses the tier. What is lost with it: on the dev corpus
/// `?q=root+canal` returns five videos, all five findable only in their
/// transcripts - still returned, by `search_transcripts()` behind
/// `/transcripts/search`, which is the endpoint built to be honest about
/// position and rank.
///
/// `search_transcripts()` and `count_transcripts()` are that endpoint's query,
/// which the API previously assembled as a SQL string per request.
///
/// `match_tier` is not renumbered. Tier 0 can no longer be produced, but 1 and 2
/// keep their values so stored data and clients comparing against them keep
/// working.
#[derive(DeriveMigrationName)]
pub struct Migration;

const UP: &str = include_str!("sql/0020_search_metadata_only.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> {
        // A no-op, like 0010 through 0019. The reverse means reinstating the
        // transcript tier - a second copy of the search branches to keep in step
        // with, which is the duplication 0014 exists to prevent.
        Ok(())
    }
}