// Generated by diesel_ext

#![allow(unused)]
#![allow(clippy::all)]

use diesel::{pg::Pg, prelude::*};
use uuid::Uuid;

#[derive(Identifiable, Queryable, Selectable, AsChangeset, Debug, Clone, PartialEq, Eq, Hash)]
#[diesel(table_name = crate::db::schema::icon)]
#[diesel(check_for_backend(Pg))]
pub struct DbIcon {
    pub id: Uuid,
    pub name: String,
    pub content_type: String,
    pub url: String,
    pub path: String,
    pub width: i32,
    pub height: i32,
    pub state: Option<serde_json::Value>,
}

#[derive(Insertable, Debug)]
#[diesel(table_name =  crate::db::schema::icon)]
pub struct NewDbIcon {
    pub name: String,
    pub content_type: String,
    pub path: String,
    pub url: String,
    pub width: i32,
    pub height: i32,
    pub state: Option<serde_json::Value>,
}

#[derive(Identifiable, Queryable, AsChangeset, Selectable, Associations, Debug, Clone)]
#[diesel(table_name = crate::db::schema::ingredient)]
#[diesel(belongs_to(DbResource, foreign_key = resource))]
#[diesel(belongs_to(DbRecipe, foreign_key = recipe))]
#[diesel(check_for_backend(Pg))]
pub struct DbIngredient {
    pub id: Uuid,
    pub resource: Uuid,
    pub quantity: i32,
    pub state: Option<serde_json::Value>,
    pub recipe: Uuid,
}
#[derive(Insertable, Clone)]
#[diesel(table_name = crate::db::schema::ingredient)]
pub struct NewDbIngredient {
    pub resource: Uuid,
    pub quantity: i32,
    pub state: Option<serde_json::Value>,
    pub recipe: Uuid,
}

#[derive(Identifiable, Queryable, AsChangeset, Associations, Selectable, Debug)]
#[diesel(table_name = crate::db::schema::recipe)]
#[diesel(belongs_to(DbResource, foreign_key = resource))]
#[diesel(check_for_backend(Pg))]
pub struct DbRecipe {
    pub id: Uuid,
    pub resource: Uuid,
    pub quantity: i32,
    pub recipe_type: String,
    pub duration: i32,
    pub unit: String,
    pub state: Option<serde_json::Value>,
}

#[derive(Insertable, Debug, Clone)]
#[diesel(table_name = crate::db::schema::recipe)]
pub struct NewDbRecipe {
    pub resource: Uuid,
    pub quantity: i32,
    pub recipe_type: String,
    pub duration: i32,
    pub unit: String,
    pub state: Option<serde_json::Value>,
}

#[derive(Identifiable, Queryable, AsChangeset, Associations, Selectable, Debug, Clone)]
#[diesel(table_name = crate::db::schema::resource)]
#[diesel(belongs_to(DbIcon, foreign_key = icon))]
#[diesel(check_for_backend(Pg))]
pub struct DbResource {
    pub id: Uuid,
    pub name: String,
    pub title: String,
    pub url: Option<String>,
    pub icon: Option<Uuid>,
    pub state: Option<serde_json::Value>,
}

#[derive(Debug, Insertable, Clone, PartialEq)]
#[diesel(table_name =  crate::db::schema::resource)]
pub struct NewDbResource {
    pub name: String,
    pub title: String,
    pub url: Option<String>,
    pub icon: Option<Uuid>,
    pub state: Option<serde_json::Value>,
}
