Matching model, table and schema

This commit is contained in:
2023-07-21 20:15:06 +02:00
parent fff33c1e21
commit 9fd99acf2e
3 changed files with 21 additions and 20 deletions

View File

@@ -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
);

View File

@@ -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<String>,
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 {

View File

@@ -4,10 +4,10 @@ diesel::table! {
antennas (id) {
#[max_length = 17]
id -> Varchar,
tssi -> Nullable<Float8>,
pos_x -> Nullable<Float8>,
pos_y -> Nullable<Float8>,
pos_z -> Nullable<Float8>,
tssi -> Float8,
pos_x -> Float8,
pos_y -> Float8,
pos_z -> Float8,
comment -> Nullable<Text>,
}
}