flix_db/entity/tmdb/
seasons.rs1use flix_model::id::ShowId as FlixId;
4use flix_model::numbers::SeasonNumber;
5use flix_tmdb::model::id::ShowId;
6
7use chrono::NaiveDate;
8use sea_orm::{
9 ActiveModelBehavior, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EntityTrait,
10 EnumIter, PrimaryKeyTrait, Related, RelationDef, RelationTrait,
11};
12
13#[derive(Debug, Clone, DeriveEntityModel)]
15#[sea_orm(table_name = "flix_tmdb_seasons")]
16pub struct Model {
17 #[sea_orm(primary_key, auto_increment = false)]
19 pub tmdb_show: ShowId,
20 #[sea_orm(primary_key, auto_increment = false)]
22 pub tmdb_season: SeasonNumber,
23 pub flix_show: FlixId,
25 pub flix_season: SeasonNumber,
27 pub last_update: NaiveDate,
29}
30
31impl ActiveModelBehavior for ActiveModel {}
32
33#[derive(Debug, EnumIter, DeriveRelation)]
35pub enum Relation {
36 #[sea_orm(
38 belongs_to = "super::shows::Entity",
39 from = "Column::TmdbShow",
40 to = "super::shows::Column::TmdbId",
41 on_update = "Cascade",
42 on_delete = "Cascade"
43 )]
44 Show,
45}
46
47impl Related<super::shows::Entity> for Entity {
48 fn to() -> RelationDef {
49 Relation::Show.def()
50 }
51}