flix_db/entity/info/
seasons.rs1use flix_model::id::ShowId;
4
5use chrono::NaiveDate;
6use flix_model::numbers::SeasonNumber;
7use sea_orm::{
8 ActiveModelBehavior, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EntityTrait,
9 EnumIter, PrimaryKeyTrait, Related, RelationDef, RelationTrait,
10};
11
12#[derive(Debug, Clone, DeriveEntityModel)]
14#[sea_orm(table_name = "flix_info_seasons")]
15pub struct Model {
16 #[sea_orm(primary_key, auto_increment = false)]
18 pub show: ShowId,
19 #[sea_orm(primary_key, auto_increment = false)]
21 pub season: SeasonNumber,
22 pub title: String,
24 pub overview: String,
26 pub date: NaiveDate,
28}
29
30impl ActiveModelBehavior for ActiveModel {}
31
32#[derive(Debug, EnumIter, DeriveRelation)]
34pub enum Relation {
35 #[sea_orm(
37 belongs_to = "super::shows::Entity",
38 from = "Column::Show",
39 to = "super::shows::Column::Id",
40 on_update = "Cascade",
41 on_delete = "Cascade"
42 )]
43 Show,
44}
45
46impl Related<super::shows::Entity> for Entity {
47 fn to() -> RelationDef {
48 Relation::Show.def()
49 }
50}