db就这样了
This commit is contained in:
parent
8820ec7f69
commit
f961c56a7b
@ -1,6 +1,6 @@
|
||||
use sea_orm::{EnumIter, Iterable};
|
||||
use sea_orm_migration::prelude::extension::postgres::Type;
|
||||
use sea_orm_migration::{manager, prelude::*};
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
@ -13,7 +13,12 @@ impl MigrationTrait for Migration {
|
||||
Table::create()
|
||||
.table(LongData::Table)
|
||||
.if_not_exists()
|
||||
.col(ColumnDef::new(LongData::SaveId).integer().not_null().primary_key())
|
||||
.col(
|
||||
ColumnDef::new(LongData::SaveId)
|
||||
.integer()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(LongData::Len).string().not_null())
|
||||
.col(ColumnDef::new(LongData::Text).string().not_null())
|
||||
.foreign_key(
|
||||
|
@ -12,6 +12,21 @@ pub struct Model {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::main_data::Entity",
|
||||
from = "Column::SaveId",
|
||||
to = "super::main_data::Column::SaveId",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
MainData,
|
||||
}
|
||||
|
||||
impl Related<super::main_data::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::MainData.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
|
||||
|
||||
use super::sea_orm_active_enums::SaveTypeEnum;
|
||||
use super::sea_orm_active_enums::SaveType;
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||
@ -8,13 +8,22 @@ use sea_orm::entity::prelude::*;
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub save_id: i32,
|
||||
pub save_type: SaveTypeEnum,
|
||||
pub save_type: SaveType,
|
||||
pub blake_hash: String,
|
||||
pub len: i32,
|
||||
pub short_data: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::long_data::Entity")]
|
||||
LongData,
|
||||
}
|
||||
|
||||
impl Related<super::long_data::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::LongData.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
|
@ -3,8 +3,8 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
|
||||
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "save_type_enum")]
|
||||
pub enum SaveTypeEnum {
|
||||
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "save_type")]
|
||||
pub enum SaveType {
|
||||
#[sea_orm(string_value = "none")]
|
||||
None,
|
||||
#[sea_orm(string_value = "save")]
|
||||
|
Loading…
Reference in New Issue
Block a user