64
libertas_infra/src/db_models.rs
Normal file
64
libertas_infra/src/db_models.rs
Normal file
@@ -0,0 +1,64 @@
|
||||
use chrono::Utc;
|
||||
use serde::Deserialize;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, sqlx::Type)]
|
||||
#[sqlx(rename_all = "lowercase")]
|
||||
#[sqlx(type_name = "TEXT")]
|
||||
pub enum PostgresRole {
|
||||
User,
|
||||
Admin,
|
||||
}
|
||||
|
||||
|
||||
#[derive(sqlx::FromRow)]
|
||||
pub struct PostgresUser {
|
||||
pub id: Uuid,
|
||||
pub username: String,
|
||||
pub email: String,
|
||||
pub hashed_password: String,
|
||||
pub created_at: chrono::DateTime<Utc>,
|
||||
pub updated_at: chrono::DateTime<Utc>,
|
||||
pub role: String,
|
||||
pub storage_quota: i64,
|
||||
pub storage_used: i64,
|
||||
}
|
||||
|
||||
#[derive(sqlx::FromRow)]
|
||||
pub struct PostgresAlbum {
|
||||
pub id: uuid::Uuid,
|
||||
pub owner_id: uuid::Uuid,
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub is_public: bool,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
pub updated_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
|
||||
#[derive(sqlx::FromRow)]
|
||||
pub struct PostgresMedia {
|
||||
pub id: uuid::Uuid,
|
||||
pub owner_id: uuid::Uuid,
|
||||
pub storage_path: String,
|
||||
pub original_filename: String,
|
||||
pub mime_type: String,
|
||||
pub hash: String,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
pub extracted_location: Option<String>,
|
||||
pub width: Option<i32>,
|
||||
pub height: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, sqlx::Type, PartialEq, Eq, Deserialize)]
|
||||
#[sqlx(rename_all = "lowercase")]
|
||||
#[sqlx(type_name = "album_permission")]
|
||||
pub enum PostgresAlbumPermission {
|
||||
View,
|
||||
Contribute,
|
||||
}
|
||||
|
||||
pub struct PostgresAlbumShare {
|
||||
pub album_id: uuid::Uuid,
|
||||
pub user_id: uuid::Uuid,
|
||||
pub permission: PostgresAlbumPermission,
|
||||
}
|
||||
Reference in New Issue
Block a user