tango-core 0.3.0

The tango schema, entities, migrations, and search contract
Documentation
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "channels")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: String,
    pub handle: Option<String>,
    pub description: Option<String>,
    pub uploads_playlist_id: Option<String>,
    pub title: Option<String>,
    pub thumbnail_url: Option<String>,
    #[sea_orm(column_type = "JsonBinary", nullable)]
    pub thumbnails: Option<serde_json::Value>,
    pub subscriber_count: Option<i64>,
    pub video_count: Option<i64>,
    pub view_count: Option<i64>,
    pub hidden_subscriber_count: Option<bool>,
    pub stats_refreshed_at: Option<DateTimeWithTimeZone>,
    pub created_at: DateTimeWithTimeZone,
    pub updated_at: DateTimeWithTimeZone,
    pub last_full_sync_at: Option<DateTimeWithTimeZone>,
    /// Identity of the title filter used by the run that set
    /// `last_full_sync_at`; `all` for an unfiltered one. The incremental
    /// boundary arms only when this matches the filter in use now: a harvest
    /// that kept a subset has not stored what it excluded.
    pub last_full_sync_filter: Option<String>,
    pub latest_published_at: Option<DateTimeWithTimeZone>,
    /// playlistItems page token an interrupted v3 harvest should resume from.
    /// NULL means there is nothing outstanding.
    pub harvest_page_token: Option<String>,
    /// Product-surface gate: whether the channel is surfaced in the product.
    /// `draft` (default) means harvested but unpublished; `published` means
    /// visible through the product's public endpoints.
    #[sea_orm(column_type = "Text")]
    pub status: String,
    /// Whether channel membership is open for joining.
    pub membership_open: bool,
    /// External links shown on the channel page (`[{type, href, label?}]`).
    #[sea_orm(column_type = "JsonBinary", nullable)]
    pub links: Option<serde_json::Value>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::video::Entity")]
    Video,
}

impl Related<super::video::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::Video.def() // Changed from .into_ref() to .def()
    }
}

impl ActiveModelBehavior for ActiveModel {}