tango-core 0.3.0

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

/// Ranks transcript matches by discussion density, and adds an exact opt-in.
///
/// The default order fell through to `ts_rank_cd` for single-term queries,
/// where that is only "how often the speaker repeated the word" - a stutter
/// outranked a considered mention. `matched_terms` now leads into
/// `context_matches`, the number of matching cues within +-30 s of this one,
/// which measures the discussion rather than the repetition. `ts_rank_cd` is
/// kept below both.
///
/// `p_exact` requires the query's words literally and adjacently (on the
/// `simple` configuration, so no stemming): `?q=racing&exact=true` no longer
/// returns cues whose only match is "race" or "races".
///
/// Both the parameter list and the result type change, so this drops and
/// recreates `search_transcripts` and `count_transcripts` rather than
/// replacing them. See the SQL header for the full reasoning.
#[derive(DeriveMigrationName)]
pub struct Migration;

const UP: &str = include_str!("sql/0022_transcript_search_relevance.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 0021. The reverse means reinstating the
        // previous signatures, which are the copies 0020 and 0021 already hold
        // and would be one more place for them to drift from.
        Ok(())
    }
}