From 190861da13cb40010494a4d3bbd8af72e88fdd2d Mon Sep 17 00:00:00 2001 From: Mika Date: Wed, 9 Oct 2024 17:14:48 +0200 Subject: [PATCH] added some more needed fields to the node entity --- .env | 2 +- crates/entity/src/node.rs | 8 +++++++- .../src/m20241008_095058_create_table_node.rs | 16 +++++++++++----- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.env b/.env index c0e4b55..58ded4c 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -DATABASE_URL=postgres://apfel:apfel@localhostc:5432/apfel +DATABASE_URL=postgres://apfel:apfel@localhost:5432/apfel TOKEN_SECRET=9b2cbd156a7a7e0e530acd780fdd16e8f37fa3fd8122c74a9b7e1ce6fc67980ed0e55572be4e382679a0c13d13f0a651d15e9e877bb579e957c899eb762b1bb4 \ No newline at end of file diff --git a/crates/entity/src/node.rs b/crates/entity/src/node.rs index 2171f7c..ba10999 100644 --- a/crates/entity/src/node.rs +++ b/crates/entity/src/node.rs @@ -17,7 +17,13 @@ pub struct Model { #[sea_orm(column_type = "Float")] pub temperature: f32, #[sea_orm(column_type = "Double")] - pub battery: f64, + pub battery_minimum: f64, + #[sea_orm(column_type = "Double")] + pub battery_current: f64, + #[sea_orm(column_type = "Double")] + pub battery_maximum: f64, + #[sea_orm(column_type = "Double")] + pub voltage: f64, pub uptime: i64, pub group: Uuid, } diff --git a/crates/migration/src/m20241008_095058_create_table_node.rs b/crates/migration/src/m20241008_095058_create_table_node.rs index 4c3e056..9a7e9aa 100644 --- a/crates/migration/src/m20241008_095058_create_table_node.rs +++ b/crates/migration/src/m20241008_095058_create_table_node.rs @@ -36,7 +36,10 @@ impl MigrationTrait for Migration { .col(double(Node::CoordLa)) .col(double(Node::CoordLo)) .col(float(Node::Temperature).default(-127)) - .col(double(Node::Battery).default(-127)) + .col(double(Node::BatteryMinimum).default(-127)) + .col(double(Node::BatteryCurrent).default(-127)) + .col(double(Node::BatteryMaximum).default(-127)) + .col(double(Node::Voltage).default(-127)) .col(big_unsigned(Node::Uptime).default(0)) .col(uuid(Node::Group)) .foreign_key( @@ -71,13 +74,16 @@ impl MigrationTrait for Migration { enum Node { Table, Id, - Name, //Default mac address, kann auch geändert werden über die API + Name, Status, CoordLa, CoordLo, - Temperature, - Battery, //Measured in volts - Uptime, + Temperature, // def: -127 + BatteryMinimum, // def: -127 + BatteryCurrent, // def: -127 + BatteryMaximum, // def: -127 + Voltage, // def: -127 + Uptime, // def: 0 Group, }