Skip to content

Commit

Permalink
chore: bump generated db schema and add new fields to Queryable structs
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcur committed Mar 21, 2024
1 parent 3592341 commit 892265e
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
2 changes: 2 additions & 0 deletions astroplant-api/src/models/kit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct Kit {
pub longitude: Option<BigDecimal>,
pub privacy_public_dashboard: bool,
pub privacy_show_on_map: bool,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}

#[derive(Clone, Debug, PartialEq, Queryable, Identifiable, Associations)]
Expand Down
8 changes: 6 additions & 2 deletions astroplant-api/src/models/kit_configuration.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::schema::kit_configurations;

use chrono::{DateTime, Utc};
use diesel::pg::PgConnection;
use diesel::prelude::*;
use diesel::{Identifiable, QueryResult, Queryable};
use serde_json::json;

use crate::schema::kit_configurations;

use super::{Kit, KitId};

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Identifiable)]
Expand All @@ -31,7 +32,10 @@ pub struct KitConfiguration {
pub controller_symbol: String,
pub control_rules: serde_json::Value,
pub active: bool,
pub first_activated_at: Option<DateTime<Utc>>,
pub never_used: bool,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}

#[derive(Clone, Debug, PartialEq, Queryable, Identifiable, AsChangeset)]
Expand Down
8 changes: 7 additions & 1 deletion astroplant-api/src/models/user.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::schema::users;

use chrono::{DateTime, Utc};
use diesel::pg::PgConnection;
use diesel::prelude::*;
use diesel::{Connection, Identifiable, QueryResult, Queryable};
Expand All @@ -18,6 +19,8 @@ pub struct User {
pub email_address: String,
pub use_email_address_for_gravatar: bool,
pub gravatar_alternative: String,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}

impl User {
Expand All @@ -32,7 +35,10 @@ impl User {
.optional()
}

pub fn by_email_address(conn: &mut PgConnection, email_address: &str) -> QueryResult<Option<User>> {
pub fn by_email_address(
conn: &mut PgConnection,
email_address: &str,
) -> QueryResult<Option<User>> {
users::table
.filter(users::email_address.ilike(email_address))
.first(conn)
Expand Down
42 changes: 42 additions & 0 deletions astroplant-api/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,30 @@ diesel::table! {
///
/// (Automatically generated by Diesel.)
active -> Bool,
/// The `first_activated_at` column of the `kit_configurations` table.
///
/// Its SQL type is `Nullable<Timestamptz>`.
///
/// (Automatically generated by Diesel.)
first_activated_at -> Nullable<Timestamptz>,
/// The `never_used` column of the `kit_configurations` table.
///
/// Its SQL type is `Bool`.
///
/// (Automatically generated by Diesel.)
never_used -> Bool,
/// The `created_at` column of the `kit_configurations` table.
///
/// Its SQL type is `Timestamptz`.
///
/// (Automatically generated by Diesel.)
created_at -> Timestamptz,
/// The `updated_at` column of the `kit_configurations` table.
///
/// Its SQL type is `Timestamptz`.
///
/// (Automatically generated by Diesel.)
updated_at -> Timestamptz,
}
}

Expand Down Expand Up @@ -238,6 +256,18 @@ diesel::table! {
///
/// (Automatically generated by Diesel.)
privacy_show_on_map -> Bool,
/// The `created_at` column of the `kits` table.
///
/// Its SQL type is `Timestamptz`.
///
/// (Automatically generated by Diesel.)
created_at -> Timestamptz,
/// The `updated_at` column of the `kits` table.
///
/// Its SQL type is `Timestamptz`.
///
/// (Automatically generated by Diesel.)
updated_at -> Timestamptz,
}
}

Expand Down Expand Up @@ -617,6 +647,18 @@ diesel::table! {
/// (Automatically generated by Diesel.)
#[max_length = 255]
gravatar_alternative -> Varchar,
/// The `created_at` column of the `users` table.
///
/// Its SQL type is `Timestamptz`.
///
/// (Automatically generated by Diesel.)
created_at -> Timestamptz,
/// The `updated_at` column of the `users` table.
///
/// Its SQL type is `Timestamptz`.
///
/// (Automatically generated by Diesel.)
updated_at -> Timestamptz,
}
}

Expand Down
1 change: 1 addition & 0 deletions astroplant-api/src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ impl From<models::KitConfiguration> for KitConfiguration {
control_rules,
active,
never_used,
..
}: models::KitConfiguration,
) -> Self {
Self {
Expand Down

0 comments on commit 892265e

Please sign in to comment.