tango-core 0.3.0

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

/// Gives a transcript hit a seek position when no single cue contains every
/// term in the query.
///
/// 0011 located `start_ms` with the same AND query that matched the document.
/// Across the full 179-video corpus that meant multi-word searches usually
/// returned a result with no position at all: the document matches because the
/// words appear somewhere across ninety minutes, but a cue is a sentence or
/// two and rarely contains all of them. `search "escalation"` produced a link;
/// `search "fog machine"` did not.
///
/// The two decisions are now separated. Which documents match stays AND — a
/// document matching only some of your terms is not a result. Where to point
/// loosens to any-term, with a cue matching everything still preferred, so the
/// answer only changes in the case that previously had none. Single-word
/// queries are untouched, since the broadened query is then identical.
///
/// `CREATE OR REPLACE`, not DROP and CREATE: the signature and return type are
/// unchanged, so this is a body edit and does not disturb the overload state
/// that 0006 exists to clean up.
#[derive(DeriveMigrationName)]
pub struct Migration;

const UP: &str = include_str!("sql/0012_transcript_seek_position.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 and 0011, and the third in a row. The previous
        // definition is `sql/0011_search_transcripts.sql`; inlining another copy
        // would be a third thing to keep in step with a function that has now
        // been rewritten four times.
        //
        // That repetition is the real cost here, not this particular down. A
        // 200-line function re-issued per feature will keep needing a
        // migration, and a no-op down each time, until the parts that change
        // are separated out into their own functions.
        Ok(())
    }
}