Billy Chan 9036d27da7
Codegen SQLite (#386)
* Codegen SQLite

* Remove debugging

* Fixup

* Add SQLite "sakila.db" demo [issues]
2021-12-25 11:31:47 +08:00

76 lines
2.3 KiB
Rust

//! SeaORM Entity. Generated by sea-orm-codegen 0.4.2
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "film")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub film_id: i32,
pub title: String,
#[sea_orm(column_type = "Custom(\"BLOB\".to_owned())", nullable)]
pub description: Option<String>,
pub release_year: Option<String>,
#[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")]
pub language_id: String,
#[sea_orm(column_type = "Custom(\"BLOB\".to_owned())", nullable)]
pub original_language_id: Option<String>,
#[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")]
pub rental_duration: String,
#[sea_orm(column_type = "Decimal(Some((4, 2)))")]
pub rental_rate: Decimal,
#[sea_orm(column_type = "Custom(\"BLOB\".to_owned())", nullable)]
pub length: Option<String>,
#[sea_orm(column_type = "Decimal(Some((5, 2)))")]
pub replacement_cost: Decimal,
pub rating: Option<String>,
pub special_features: Option<String>,
pub last_update: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::language::Entity",
from = "Column::OriginalLanguageId",
to = "super::language::Column::LanguageId",
on_update = "NoAction",
on_delete = "NoAction"
)]
Language2,
#[sea_orm(
belongs_to = "super::language::Entity",
from = "Column::LanguageId",
to = "super::language::Column::LanguageId",
on_update = "NoAction",
on_delete = "NoAction"
)]
Language1,
#[sea_orm(has_many = "super::film_actor::Entity")]
FilmActor,
#[sea_orm(has_many = "super::film_category::Entity")]
FilmCategory,
#[sea_orm(has_many = "super::inventory::Entity")]
Inventory,
}
impl Related<super::film_actor::Entity> for Entity {
fn to() -> RelationDef {
Relation::FilmActor.def()
}
}
impl Related<super::film_category::Entity> for Entity {
fn to() -> RelationDef {
Relation::FilmCategory.def()
}
}
impl Related<super::inventory::Entity> for Entity {
fn to() -> RelationDef {
Relation::Inventory.def()
}
}
impl ActiveModelBehavior for ActiveModel {}