feat(health): patient_devices 增强 — status/firmware/manufacturer/connection_type/metadata
- 新增迁移:添加 status/firmware_version/manufacturer/connection_type/metadata 列 - 更新 Entity:新增对应字段(含默认值) - 修复 device_reading_service 自动绑定设备时填充新字段
This commit is contained in:
@@ -104,6 +104,8 @@ mod m20260502_000101_seed_health_dictionaries;
|
||||
mod m20260502_000102_seed_warning_thresholds;
|
||||
mod m20260502_000103_seed_follow_up_template_menu;
|
||||
mod m20260504_000104_create_vital_signs_daily;
|
||||
mod m20260504_000105_alter_patient_devices_add_status;
|
||||
mod m20260504_000106_create_api_clients;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
@@ -215,6 +217,8 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20260502_000102_seed_warning_thresholds::Migration),
|
||||
Box::new(m20260502_000103_seed_follow_up_template_menu::Migration),
|
||||
Box::new(m20260504_000104_create_vital_signs_daily::Migration),
|
||||
Box::new(m20260504_000105_alter_patient_devices_add_status::Migration),
|
||||
Box::new(m20260504_000106_create_api_clients::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Alias::new("patient_devices"))
|
||||
.add_column(
|
||||
ColumnDef::new(Alias::new("status"))
|
||||
.string()
|
||||
.not_null()
|
||||
.default("active"),
|
||||
)
|
||||
.add_column(ColumnDef::new(Alias::new("firmware_version")).string())
|
||||
.add_column(ColumnDef::new(Alias::new("manufacturer")).string())
|
||||
.add_column(
|
||||
ColumnDef::new(Alias::new("connection_type"))
|
||||
.string()
|
||||
.not_null()
|
||||
.default("ble"),
|
||||
)
|
||||
.add_column(ColumnDef::new(Alias::new("metadata")).json_binary())
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Alias::new("patient_devices"))
|
||||
.drop_column(Alias::new("status"))
|
||||
.drop_column(Alias::new("firmware_version"))
|
||||
.drop_column(Alias::new("manufacturer"))
|
||||
.drop_column(Alias::new("connection_type"))
|
||||
.drop_column(Alias::new("metadata"))
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user