45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
//! `SeaORM` Entity for customer shipping/contact profiles. Hand-written to match
|
|
//! the `customer_profiles` migration (1:1 with `users` via a unique `user_id`).
|
|
|
|
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
|
#[sea_orm(table_name = "customer_profiles")]
|
|
pub struct Model {
|
|
pub created_at: DateTimeWithTimeZone,
|
|
pub updated_at: DateTimeWithTimeZone,
|
|
#[sea_orm(primary_key)]
|
|
pub id: i32,
|
|
#[sea_orm(unique)]
|
|
pub user_id: i32,
|
|
pub company_name: Option<String>,
|
|
pub company_id: Option<String>,
|
|
pub tax_id: Option<String>,
|
|
pub vat_id: Option<String>,
|
|
pub phone_prefix: Option<String>,
|
|
pub phone: Option<String>,
|
|
pub address: Option<String>,
|
|
pub city: Option<String>,
|
|
pub zip: Option<String>,
|
|
pub country: Option<String>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {
|
|
#[sea_orm(
|
|
belongs_to = "super::users::Entity",
|
|
from = "Column::UserId",
|
|
to = "super::users::Column::Id",
|
|
on_update = "Cascade",
|
|
on_delete = "Cascade"
|
|
)]
|
|
Users,
|
|
}
|
|
|
|
impl Related<super::users::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::Users.def()
|
|
}
|
|
}
|