Change to mysql, add extra fields, add changebale interval
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use diesel::pg::PgConnection;
|
||||
use diesel::MysqlConnection as DbConnection;
|
||||
use diesel::prelude::*;
|
||||
use diesel_migrations::{EmbeddedMigrations, MigrationHarness, embed_migrations};
|
||||
|
||||
@@ -7,8 +7,8 @@ pub mod schema;
|
||||
|
||||
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!();
|
||||
|
||||
pub fn init_db(database_url: &str) -> PgConnection {
|
||||
let mut connection = PgConnection::establish(database_url)
|
||||
pub fn init_db(database_url: &str) -> DbConnection {
|
||||
let mut connection = DbConnection::establish(database_url)
|
||||
.unwrap_or_else(|e| panic!("Error connecting to database: {e}"));
|
||||
|
||||
connection
|
||||
|
||||
@@ -4,7 +4,7 @@ use diesel::prelude::*;
|
||||
|
||||
#[derive(Debug, Queryable, Selectable)]
|
||||
#[diesel(table_name = crate::db::schema::antennas)]
|
||||
#[diesel(check_for_backend(diesel::pg::Pg))]
|
||||
#[diesel(check_for_backend(diesel::mysql::Mysql))]
|
||||
pub struct Antenna {
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
@@ -22,7 +22,7 @@ pub struct NewAntenna {
|
||||
|
||||
#[derive(Debug, Queryable, Selectable)]
|
||||
#[diesel(table_name = crate::db::schema::client_readings)]
|
||||
#[diesel(check_for_backend(diesel::pg::Pg))]
|
||||
#[diesel(check_for_backend(diesel::mysql::Mysql))]
|
||||
pub struct ClientReading {
|
||||
pub id: i64,
|
||||
pub ip: String,
|
||||
@@ -30,6 +30,11 @@ pub struct ClientReading {
|
||||
pub antenna_ip: String,
|
||||
pub db_reading: i32,
|
||||
pub read_at: NaiveDateTime,
|
||||
pub tx_ccq: i32,
|
||||
pub rx_ccq: i32,
|
||||
pub radio_name: String,
|
||||
pub tx_rate: String,
|
||||
pub rx_rate: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Insertable)]
|
||||
@@ -39,4 +44,9 @@ pub struct NewClientReading {
|
||||
pub mac: String,
|
||||
pub antenna_ip: String,
|
||||
pub db_reading: i32,
|
||||
pub tx_ccq: i32,
|
||||
pub rx_ccq: i32,
|
||||
pub radio_name: String,
|
||||
pub tx_rate: String,
|
||||
pub rx_rate: String,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// @generated automatically by Diesel CLI.
|
||||
// Written manually because diesel cant fucking read the db properly for some reason
|
||||
|
||||
diesel::table! {
|
||||
antennas (id) {
|
||||
@@ -17,6 +17,11 @@ diesel::table! {
|
||||
antenna_ip -> Text,
|
||||
db_reading -> Int4,
|
||||
read_at -> Timestamp,
|
||||
tx_ccq -> Int4,
|
||||
rx_ccq -> Int4,
|
||||
radio_name -> Varchar,
|
||||
tx_rate -> Varchar,
|
||||
rx_rate -> Varchar,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user