perf: migrate all user/session/auth IDs from VARCHAR(36) to native UUID
- Schema: all ~15 VARCHAR(36) columns → UUID with DEFAULT gen_random_uuid() - Domain entities: User, Session, DeviceCode, AppPassword, Share → id: Uuid - DTOs: CurrentUser.id → Uuid (API boundary DTOs keep String for JSON) - Auth middleware: parse JWT claims.sub (String) → Uuid at boundary - All repository traits, port traits, service impls updated end-to-end - Handlers: pass Uuid by value (Copy, 16 bytes) instead of String refs - Settings chain: updated_by column → Uuid (was text, caused setup crash) - Removed ~650 lines of String↔Uuid conversion boilerplate - Eliminates per-request heap allocations for ID cloning - 16-byte binary comparison vs 36-byte string comparison in all queries - Native UUID indexing in PostgreSQL (btree on 16 bytes vs 36-char text) 85 files changed, 1090 insertions(+), 1739 deletions(-)
This commit is contained in:
@@ -108,7 +108,7 @@ impl ChunkedUploadHandler {
|
||||
// ── Quota enforcement ────────────────────────────────────
|
||||
if let Some(storage_svc) = state.storage_usage_service.as_ref()
|
||||
&& let Err(err) = storage_svc
|
||||
.check_storage_quota(&auth_user.id, request.total_size)
|
||||
.check_storage_quota(auth_user.id, request.total_size)
|
||||
.await
|
||||
{
|
||||
tracing::warn!(
|
||||
@@ -146,7 +146,7 @@ impl ChunkedUploadHandler {
|
||||
|
||||
match chunked_service
|
||||
.create_session(
|
||||
&auth_user.id,
|
||||
auth_user.id,
|
||||
request.filename,
|
||||
request.folder_id,
|
||||
content_type,
|
||||
@@ -192,7 +192,7 @@ impl ChunkedUploadHandler {
|
||||
match chunked_service
|
||||
.upload_chunk(
|
||||
&upload_id,
|
||||
&auth_user.id,
|
||||
auth_user.id,
|
||||
params.chunk_index,
|
||||
body,
|
||||
checksum,
|
||||
@@ -233,7 +233,7 @@ impl ChunkedUploadHandler {
|
||||
) -> impl IntoResponse {
|
||||
let chunked_service = &state.core.chunked_upload_service;
|
||||
|
||||
match chunked_service.get_status(&upload_id, &auth_user.id).await {
|
||||
match chunked_service.get_status(&upload_id, auth_user.id).await {
|
||||
Ok(status) => Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
.header(header::CONTENT_TYPE, "application/json")
|
||||
@@ -268,7 +268,7 @@ impl ChunkedUploadHandler {
|
||||
// Assemble chunks (hash-on-write: SHA-256 computed during assembly)
|
||||
let (assembled_path, filename, folder_id, content_type, total_size, hash) =
|
||||
match chunked_service
|
||||
.complete_upload(&upload_id, &auth_user.id)
|
||||
.complete_upload(&upload_id, auth_user.id)
|
||||
.await
|
||||
{
|
||||
Ok(result) => result,
|
||||
@@ -299,7 +299,7 @@ impl ChunkedUploadHandler {
|
||||
Ok(file) => {
|
||||
// Cleanup session
|
||||
let _ = chunked_service
|
||||
.finalize_upload(&upload_id, &auth_user.id)
|
||||
.finalize_upload(&upload_id, auth_user.id)
|
||||
.await;
|
||||
|
||||
tracing::info!(
|
||||
@@ -338,7 +338,7 @@ impl ChunkedUploadHandler {
|
||||
let chunked_service = &state.core.chunked_upload_service;
|
||||
|
||||
match chunked_service
|
||||
.cancel_upload(&upload_id, &auth_user.id)
|
||||
.cancel_upload(&upload_id, auth_user.id)
|
||||
.await
|
||||
{
|
||||
Ok(_) => StatusCode::NO_CONTENT.into_response(),
|
||||
|
||||
Reference in New Issue
Block a user