diff --git a/kairo-common/migrations/2023-06-18-164844_create_antennas/up.sql b/kairo-common/migrations/2023-06-18-164844_create_antennas/up.sql index f5902a1..57332ea 100644 --- a/kairo-common/migrations/2023-06-18-164844_create_antennas/up.sql +++ b/kairo-common/migrations/2023-06-18-164844_create_antennas/up.sql @@ -2,9 +2,9 @@ CREATE TABLE antennas ( id VARCHAR(17) PRIMARY KEY, - tssi DOUBLE PRECISION, - pos_x DOUBLE PRECISION, - pos_y DOUBLE PRECISION, - pos_z DOUBLE PRECISION, + tssi DOUBLE PRECISION NOT NULL, + pos_x DOUBLE PRECISION NOT NULL, + pos_y DOUBLE PRECISION NOT NULL, + pos_z DOUBLE PRECISION NOT NULL, comment TEXT ); \ No newline at end of file diff --git a/kairo-common/src/models/antenna.rs b/kairo-common/src/models/antenna.rs index 9786b91..e226be6 100644 --- a/kairo-common/src/models/antenna.rs +++ b/kairo-common/src/models/antenna.rs @@ -1,28 +1,29 @@ -use std::f64::consts::PI; use diesel::prelude::*; +use std::f64::consts::PI; use crate::{unit_conversion::UnitsConversion, Point}; -#[derive(Debug, Clone, Default,Queryable, Selectable)] +#[derive(Debug, Clone, Default, Queryable, Selectable, serde::Serialize, serde::Deserialize)] +#[diesel(check_for_backend(diesel::pg::Pg))] #[diesel(table_name = crate::schema::antennas)] pub struct Antenna { pub id: String, pub tssi: f64, + pub pos_x: f64, + pub pos_y: f64, + pub pos_z: f64, pub comment: Option, - pos_x: f64, - pos_y: f64, - pos_z: f64, } -#[derive(Insertable)] +#[derive(Debug, Clone, Copy, Insertable, AsChangeset, serde::Deserialize)] #[diesel(table_name = crate::schema::antennas)] pub struct NewAntenna<'a> { - id: &'a str, - comment: Option<&'a str>, - tssi: f64, - pos_x: f64, - pos_y: f64, - pos_z: f64, + pub id: &'a str, + pub tssi: f64, + pub pos_x: f64, + pub pos_y: f64, + pub pos_z: f64, + pub comment: Option<&'a str>, } impl Antenna { diff --git a/kairo-common/src/schema.rs b/kairo-common/src/schema.rs index 17c9565..d0a6a02 100644 --- a/kairo-common/src/schema.rs +++ b/kairo-common/src/schema.rs @@ -4,10 +4,10 @@ diesel::table! { antennas (id) { #[max_length = 17] id -> Varchar, - tssi -> Nullable, - pos_x -> Nullable, - pos_y -> Nullable, - pos_z -> Nullable, + tssi -> Float8, + pos_x -> Float8, + pos_y -> Float8, + pos_z -> Float8, comment -> Nullable, } }