先写一部分shipdata
This commit is contained in:
parent
69b75d8e8f
commit
f71de5c149
@ -2,8 +2,10 @@ use sea_orm::{ConnectionTrait, DatabaseBackend, DatabaseConnection, Statement};
|
||||
|
||||
use crate::config::ConfigFile;
|
||||
|
||||
pub mod main_data_table;
|
||||
pub mod full_data_view;
|
||||
pub mod long_data_table;
|
||||
pub mod main_data_table;
|
||||
pub mod ships_table;
|
||||
|
||||
pub mod db_names {
|
||||
/// 主数据表
|
||||
@ -18,7 +20,6 @@ pub mod db_names {
|
||||
pub const SEA_ORM_TABLE: &str = "seaql_migrations";
|
||||
}
|
||||
|
||||
|
||||
pub const CURRENT_DB_VERSION: i32 = 1;
|
||||
|
||||
pub const TEXT_DATA_MAX_LEN: usize = 1024;
|
||||
|
39
sr_download/src/db_part/defines/long_data_table.rs
Normal file
39
sr_download/src/db_part/defines/long_data_table.rs
Normal file
@ -0,0 +1,39 @@
|
||||
use sea_orm::sea_query::{ColumnDef, ForeignKey, Table};
|
||||
use sea_orm::{DatabaseBackend, DeriveIden, ForeignKeyAction, Iden, Statement};
|
||||
|
||||
use super::main_data_table::MainData;
|
||||
|
||||
pub fn long_data_table() -> Statement {
|
||||
let mut table = Table::create();
|
||||
table
|
||||
.table(LongData::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(LongData::SaveId)
|
||||
.integer()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name(LongData::SaveId.to_string())
|
||||
.to(MainData::Table, MainData::SaveId)
|
||||
.from(LongData::Table, LongData::SaveId)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
.on_update(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.col(ColumnDef::new(LongData::Len).big_integer().not_null())
|
||||
.col(ColumnDef::new(LongData::Text).string().not_null());
|
||||
DatabaseBackend::Postgres.build(&table)
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
pub enum LongData {
|
||||
Table,
|
||||
/// 存档 ID
|
||||
SaveId,
|
||||
/// 二次校验长度(?)
|
||||
Len,
|
||||
/// 1024 ~ 2MB 长度的数据
|
||||
Text,
|
||||
}
|
@ -3,7 +3,7 @@ use sea_orm::{DatabaseBackend, DeriveIden, EnumIter, Iterable, Statement};
|
||||
|
||||
use super::TEXT_DATA_MAX_LEN;
|
||||
|
||||
pub async fn main_table() -> Statement {
|
||||
pub fn main_table() -> Statement {
|
||||
let mut table = Table::create();
|
||||
table
|
||||
.table(MainData::Table)
|
||||
|
44
sr_download/src/db_part/defines/ships_table.rs
Normal file
44
sr_download/src/db_part/defines/ships_table.rs
Normal file
@ -0,0 +1,44 @@
|
||||
use sea_orm::sea_query::{ColumnDef, ForeignKey, Table};
|
||||
use sea_orm::{DatabaseBackend, DeriveIden, ForeignKeyAction, Iden, Statement};
|
||||
|
||||
use super::main_data_table::MainData;
|
||||
|
||||
pub fn ships_table() -> Statement {
|
||||
let mut table = Table::create();
|
||||
table
|
||||
.table(Ships::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Ships::SaveId)
|
||||
.integer()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name(Ships::SaveId.to_string())
|
||||
.to(MainData::Table, MainData::SaveId)
|
||||
.from(Ships::Table, Ships::SaveId)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
.on_update(ForeignKeyAction::Cascade),
|
||||
);
|
||||
DatabaseBackend::Postgres.build(&table)
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
pub enum Ships {
|
||||
Table,
|
||||
/// 存档 ID
|
||||
SaveId,
|
||||
/// 解析过的 xml 数据
|
||||
/// 这样就不用每次解析一遍了
|
||||
XmlData,
|
||||
/// 飞船质量
|
||||
/// (按照原版数据计算, 经过比例缩放)
|
||||
Mass,
|
||||
/// 是否检查到了使用 mod 的迹象
|
||||
/// 比如 多 pod 之类的
|
||||
ModUsed,
|
||||
/// 是否有 docxConnection (xml使用迹象)
|
||||
DocxConnectionUsed,
|
||||
}
|
Loading…
Reference in New Issue
Block a user