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 KiB
🕵️ DB Migrations Audit V1
Date: 04/12/2025
Author: Staff Engineer / DBA
Scope: veza-backend-api Database Schema & Migrations
1. Executive Summary
The current database schema is in a transitional "Hybrid" state, resulting from an incomplete migration from INT/BIGINT to UUID. While core entities (users, tracks, playlists) have been migrated to UUIDs, the surrounding infrastructure (secondary tables, audit logs, tokens, junction tables) remains largely on BIGINT sequences.
This audit establishes the roadmap to move from this "Lab/Repair" state to a Canonical V1 Schema that is purely UUID-based, consistent, and production-ready.
Note on Source of Truth: The file docs/ORIGIN_DATABASE_SCHEMA.md was referenced but not found. This audit treats docs/UUID_DB_MIGRATION_PLAN.md (Target Architecture) and the current veza_uuid_lab_schema.sql (Entity Inventory) as the combined Source of Truth.
2. Gap Analysis: Lab Schema vs. Target V1
2.1 Core Conformance (Status: ✅ Mostly Good)
The core entities align with the UUID target.
- Users:
idis UUID. - Tracks:
idis UUID. - Playlists:
idis UUID. - RBAC (Roles/Permissions):
idis UUID.
2.2 Critical Deficiencies (Status: ❌ Needs Fix)
The following tables currently use BIGINT (SERIAL) Primary Keys in the Lab Schema. In V1, these MUST be UUID.
| Domain | Table | Current PK | Target V1 PK |
|---|---|---|---|
| Auth | refresh_tokens |
bigint |
UUID |
| Auth | password_reset_tokens |
bigint |
UUID |
| Auth | email_verification_tokens |
bigint |
UUID |
| Auth | user_sessions |
bigint |
UUID |
| Streaming | bitrate_adaptation_logs |
bigint |
UUID |
| Streaming | hls_streams |
bigint |
UUID |
| Streaming | hls_transcode_queue |
bigint |
UUID |
| Streaming | playback_analytics |
bigint |
UUID |
| Streaming | track_comments |
bigint |
UUID |
| Streaming | track_history |
bigint |
UUID |
| Streaming | track_likes |
bigint |
UUID |
| Streaming | track_plays |
bigint |
UUID |
| Streaming | track_shares |
bigint |
UUID |
| Streaming | track_versions |
bigint |
UUID |
| Social | playlist_collaborators |
bigint |
UUID |
| Social | playlist_follows |
bigint |
UUID |
| Chat (Legacy) | rooms |
bigint |
UUID |
2.3 Structural Issues
- Inconsistent Defaults: Some tables use
now(), othersCURRENT_TIMESTAMP. V1 will standardize onTIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP. - Missing
deleted_at: Several tables lacking soft-delete where implied by domain (e.g.,playlist_collaboratorshas it, butplaylist_tracksdoes not). V1 will apply soft-deletes consistently for user-managed resources. - Foreign Key Constraints: Many FKs in the Lab schema lack explicit
ON DELETErules. V1 will enforceON DELETE CASCADEfor ownership relationships (e.g., User -> RefreshToken) andON DELETE SET NULLorRESTRICTfor references.
3. Schema Governance & Separation
Per UUID_DB_MIGRATION_PLAN.md:
publicSchema: Owned byveza-backend-api. Containsusers,auth,tracks,playlists(and their satellite tables).chatSchema: Owned byveza-chat-server. Containsconversations,messages.
V1 Scope Decision:
The veza-backend-api migrations will strictly manage the public schema.
- Legacy
roomstable (if still used by Go) will be migrated to UUID inpublic. - New
chatschema tables will NOT be created by these migrations to respect the separation of concerns, unless a specific "Schema Init" migration is required for integration tests.
4. Recommendation
Proceed with the V1 "Clean Slate" Strategy:
- Archive all existing
001...072migrations. - Create a fresh set of migrations (
001...999) that define the tables correctly (UUID) from the start. - Do not implement "repair" scripts; implement the "final state".