separation of database (#1)

Reviewed-on: #1
This commit is contained in:
2025-11-03 02:26:19 +00:00
parent 8b98df745c
commit 39ee8d52a4
21 changed files with 407 additions and 140 deletions

View 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,
}