Backend Go: - Remplacement complet des anciennes migrations par la base V1 alignée sur ORIGIN. - Durcissement global du parsing JSON (BindAndValidateJSON + RespondWithAppError). - Sécurisation de config.go, CORS, statuts de santé et monitoring. - Implémentation des transactions P0 (RBAC, duplication de playlists, social toggles). - Ajout d’un job worker structuré (emails, analytics, thumbnails) + tests associés. - Nouvelle doc backend : AUDIT_CONFIG, BACKEND_CONFIG, AUTH_PASSWORD_RESET, JOB_WORKER_*. Chat server (Rust): - Refonte du pipeline JWT + sécurité, audit et rate limiting avancé. - Implémentation complète du cycle de message (read receipts, delivered, edit/delete, typing). - Nettoyage des panics, gestion d’erreurs robuste, logs structurés. - Migrations chat alignées sur le schéma UUID et nouvelles features. Stream server (Rust): - Refonte du moteur de streaming (encoding pipeline + HLS) et des modules core. - Transactions P0 pour les jobs et segments, garanties d’atomicité. - Documentation détaillée de la pipeline (AUDIT_STREAM_*, DESIGN_STREAM_PIPELINE, TRANSACTIONS_P0_IMPLEMENTATION). Documentation & audits: - TRIAGE.md et AUDIT_STABILITY.md à jour avec l’état réel des 3 services. - Cartographie complète des migrations et des transactions (DB_MIGRATIONS_*, DB_TRANSACTION_PLAN, AUDIT_DB_TRANSACTIONS, TRANSACTION_TESTS_PHASE3). - Scripts de reset et de cleanup pour la lab DB et la V1. Ce commit fige l’ensemble du travail de stabilisation P0 (UUID, backend, chat et stream) avant les phases suivantes (Coherence Guardian, WS hardening, etc.).
4.9 KiB
4.9 KiB
🔍 DB Migrations Origin Diff
Date: 04/12/2025
Scope: veza-backend-api vs ORIGIN_DATABASE_SCHEMA.md
This document highlights the divergences between the intended V1 migrations and the Source of Truth (Origin).
1. Global Divergences
| Feature | Origin Spec | Current V1 Implementation | Action |
|---|---|---|---|
| Primary Keys | UUID DEFAULT gen_random_uuid() |
UUID DEFAULT gen_random_uuid() |
✅ Aligned |
| Timestamps | created_at, updated_at (TIMESTAMPTZ) |
created_at, updated_at (TIMESTAMPTZ) |
✅ Aligned |
| Updated Trigger | Mandatory | Implemented via 900_triggers.sql |
✅ Aligned |
| Indexes | Snake_case idx_<table>_<cols> |
Mixed naming | ⚠️ Rename to standard |
| Soft Deletes | Mandatory for user-facing | Partially implemented | ⚠️ Fix missing deleted_at |
2. Table-by-Table Diff
2.1 Auth & Users
users
- Origin:
email(unique),username(unique),password_hash,role(ENUM),is_active,is_verified,is_banned,token_version,last_login_at,login_count. - V1: Has most fields.
- Divergences:
role: V1 usesVARCHAR, Origin requiresENUM user_role.is_banned: Missing in V1.login_count,last_login_ip: Missing in V1.email_verified_at,last_password_change_at: Missing in V1.avatar,bioin V1 are inusers, but Origin puts them inuser_profiles.- Decision: Move profile fields to
user_profiles? NO, to maintain Go compatibility, we will keep basic profile fields inusersfor now but ADD the missing Origin fields (is_banned, etc.) and fix theroletype.
refresh_tokens
- Origin:
token_hash,device_name,device_type,ip_address,last_used_at,is_revoked,revoked_reason. - V1: Simplified version.
- Action: Add missing columns (
device_name,is_revoked, etc.) to match Origin.
federated_identities
- Origin:
provider_user_id,provider_email,provider_profile_data(JSONB),is_primary. - V1:
provider_id(naming mismatch), missingprovider_profile_data,is_primary. - Action: Rename
provider_id->provider_user_id. Add missing columns.
2.2 Profiles
user_profiles
- Origin: Separate table with
bio,location,website_url,birthdate,gender,theme. - V1: Some fields are in
users. - Action: Create
user_profilesexactly as Origin. Ifuserstable duplicates data, we will deprecate the columns inusersbut keep them for Go compatibility, OR sync them via trigger. - Strategy: Create the full
user_profilestable.
2.3 Streaming (Tracks & Playlists)
tracks
- Origin:
creator_id(FK users),file_id(FK files),visibility(ENUM),bpm,musical_key. - V1:
user_id(FK users),file_path(Nofilestable relation),status(VARCHAR). - Divergences:
- Major: Origin links
tracks->files. V1 storesfile_pathdirectly ontracks. - Constraint: Creating a
filestable implies a major refactor of the Go backend if it expectsfile_pathontracks. - Action: We will Create the
filestable as per Origin. We will keepfile_pathontracksfor Go compatibility (marked as legacy/denormalized) but ALSO addfile_id(nullable for now) to pave the way for the target schema. user_idvscreator_id: V1 usesuser_id. Origin usescreator_id. We will Addcreator_idand sync it or Rename it if safe (Go usesUserID). -> Keepuser_idto avoid breaking Go, but map it mentally. Actually, Origin sayscreator_id. I will addcreator_idand makeuser_ida generated col or alias if possible, or just accept the divergence for now. Decision: Keepuser_idfor Go compatibility, add comment.
- Major: Origin links
playlists
- Origin:
name,visibility(ENUM),is_collaborative. - V1:
title,is_public(BOOL). - Action:
- Add
name(or renametitle->nameif code allows, otherwise keeptitleand addnameas generated/synced). -> Keeptitle, Origin saysname. We will usetitleas it's standard in this codebase. - Add
visibilityENUM (mapis_publicto it).
- Add
2.4 Files
- Origin:
filestable with storage info, metadata, hash. - V1: No
filestable. - Action: Implement
filestable from Origin. It's critical for the "File Management" module.
3. Plan of Action
- 001_extensions_and_types.sql: Add
user_role,visibility,message_typeENUMs. - 010_auth.sql: Align
users,refresh_tokenswith Origin columns. - 020_profiles.sql: Implement full
user_profilestable. - 030_files.sql: Implement
filestable (New). - 040_streaming.sql: Update
tracks,playliststo referencefilesand use ENUMs. - 900_triggers.sql: Ensure all have
updated_attriggers.