flix_db/entity/content/
seasons.rs1use flix_model::id::{LibraryId, ShowId};
4
5use seamantic::model::path::PathBytes;
6
7use flix_model::numbers::SeasonNumber;
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_seasons")]
16pub struct Model {
17 #[sea_orm(primary_key, auto_increment = false)]
19 pub show: ShowId,
20 #[sea_orm(primary_key, auto_increment = false)]
22 pub season: SeasonNumber,
23 pub slug: String,
25 pub library: LibraryId,
27 pub directory: PathBytes,
29 pub relative_poster_path: Option<PathBytes>,
31}
32
33impl ActiveModelBehavior for ActiveModel {}
34
35#[derive(Debug, EnumIter, DeriveRelation)]
37pub enum Relation {
38 #[sea_orm(
40 belongs_to = "super::libraries::Entity",
41 from = "Column::Library",
42 to = "super::libraries::Column::Id",
43 on_update = "Cascade",
44 on_delete = "Cascade"
45 )]
46 Library,
47}
48
49impl Related<super::libraries::Entity> for Entity {
50 fn to() -> RelationDef {
51 Relation::Library.def()
52 }
53}