- Archiver 131 .md dans docs/archive/root-md/ - Archiver 22 .json dans docs/archive/root-json/ - Conserver 7 .md utiles (README, CONTRIBUTING, CHANGELOG, etc.) - Conserver package.json, package-lock.json, turbo.json - Ajouter README d'index dans chaque archive
32 KiB
Rapport Migration UUID — Projet Veza
Date : 2025-01-27
Objectif : Cartographier exhaustivement l'état de la migration UUID dans le monorepo et produire un plan de nettoyage pour supprimer définitivement tout le code legacy.
Résumé exécutif
- Services analysés : 6 (backend-api, chat-server, stream-server, web, mobile, desktop)
- Fichiers legacy à supprimer : 45+ (migrations_legacy/, *.legacy, dossiers backup)
- Modifications de code requises : ~15 fichiers avec patterns INT à corriger
- TODOs/FIXMEs liés à la migration : 8 identifiés
- Estimation temps nettoyage : 4-6 heures
État global : La migration UUID est largement complétée dans le backend Go, mais il reste :
- Un dossier
migrations_legacy/complet (44 fichiers SQL) - Des fichiers
.legacy - Des TODOs/FIXMEs indiquant une migration partielle
- Le chat-server Rust utilise encore des
i64pour certains IDs (cohabitation INT/UUID)
1. Cartographie complète des services
1.1 Services du monorepo
| Service | Langage | A des migrations | A migrations_legacy | ORM/DB | État UUID |
|---|---|---|---|---|---|
| veza-backend-api | Go | ✅ migrations/ |
✅ migrations_legacy/ (44 fichiers) |
GORM | ✅ Principalement migré |
| veza-chat-server | Rust | ✅ migrations/ |
❌ | SQLx | ⚠️ Mixte (i64 + UUID) |
| veza-stream-server | Rust | ❌ (pas de migrations SQL) | ❌ | SQLx | ✅ UUID |
| apps/web | React/TS | ❌ | ❌ | - | ✅ string (UUID) |
| veza-mobile | React Native | ❌ | ❌ | - | ✅ string (UUID) |
| veza-desktop | Electron/TS | ❌ | ❌ | - | ✅ string (UUID) |
1.2 Fichiers de migration par service
veza-backend-api/migrations/ (MODERN - UUID)
| Fichier | Tables impactées | Type d'ID | Notes |
|---|---|---|---|
| 001_extensions_and_types.sql | - | - | Extensions PostgreSQL |
| 010_auth_and_users.sql | users | UUID | ✅ |
| 020_rbac_and_profiles.sql | roles, permissions | UUID | ✅ |
| 030_files_management.sql | files | UUID | ✅ |
| 040_streaming_core.sql | tracks, playlists | UUID | ✅ |
| 041_streaming_analytics.sql | playback_analytics | UUID | ✅ |
| 042_media_processing.sql | hls_streams, transcodes | UUID | ✅ |
| 050_legacy_chat.sql | messages, rooms | UUID | ✅ |
| 900_triggers_and_functions.sql | - | - | Triggers |
Total : 9 fichiers modernes
veza-backend-api/migrations_legacy/ (À SUPPRIMER)
| Fichier | Tables impactées | Type d'ID | Équivalent modern | Statut |
|---|---|---|---|---|
| 001_create_users.sql | users | INT → UUID | 010_auth_and_users.sql | ✅ Remplacé |
| 018_create_email_verification_tokens.sql | email_verification_tokens | INT | 010_auth_and_users.sql | ✅ Remplacé |
| 019_create_password_reset_tokens.sql | password_reset_tokens | INT | 010_auth_and_users.sql | ✅ Remplacé |
| 020_create_sessions.sql | sessions | INT → UUID | 010_auth_and_users.sql | ✅ Remplacé |
| 021_add_profile_privacy.sql | users | - | 010_auth_and_users.sql | ✅ Remplacé |
| 022_add_profile_slug.sql | users | - | 010_auth_and_users.sql | ✅ Remplacé |
| 023_create_roles_permissions.sql | roles, permissions | INT → UUID | 020_rbac_and_profiles.sql | ✅ Remplacé |
| 024_seed_permissions.sql | permissions | - | 020_rbac_and_profiles.sql | ✅ Remplacé |
| 025_create_tracks.sql | tracks | INT → UUID | 040_streaming_core.sql | ✅ Remplacé |
| 026_add_track_status.sql | tracks | - | 040_streaming_core.sql | ✅ Remplacé |
| 027_create_track_likes.sql | track_likes | INT → UUID | 040_streaming_core.sql | ✅ Remplacé |
| 028_create_track_comments.sql | track_comments | INT → UUID | 040_streaming_core.sql | ✅ Remplacé |
| 029_create_track_plays.sql | track_plays | INT → UUID | 040_streaming_core.sql | ✅ Remplacé |
| 030_create_playlists.sql | playlists | INT → UUID | 040_streaming_core.sql | ✅ Remplacé |
| 031_create_playlist_collaborators.sql | playlist_collaborators | INT → UUID | 040_streaming_core.sql | ✅ Remplacé |
| 031_create_track_shares.sql | track_shares | INT → UUID | 040_streaming_core.sql | ✅ Remplacé |
| 032_create_playlist_follows.sql | playlist_follows | INT → UUID | 040_streaming_core.sql | ✅ Remplacé |
| 032_create_track_versions.sql | track_versions | INT → UUID | 040_streaming_core.sql | ✅ Remplacé |
| 033_create_track_history.sql | track_history | INT → UUID | 041_streaming_analytics.sql | ✅ Remplacé |
| 034_create_hls_streams_table.sql | hls_streams | INT → UUID | 042_media_processing.sql | ✅ Remplacé |
| 035_create_hls_transcode_queue.sql | hls_transcode_queue | INT → UUID | 042_media_processing.sql | ✅ Remplacé |
| 036_create_bitrate_adaptation_logs.sql | bitrate_adaptation_logs | INT → UUID | 041_streaming_analytics.sql | ✅ Remplacé |
| 037_create_playback_analytics.sql | playback_analytics | INT → UUID | 041_streaming_analytics.sql | ✅ Remplacé |
| 038_add_playback_analytics_indexes.sql | playback_analytics | - | 041_streaming_analytics.sql | ✅ Remplacé |
| 040_create_refresh_tokens.sql | refresh_tokens | INT → UUID | 010_auth_and_users.sql | ✅ Remplacé |
| 041_create_rooms.sql | rooms | INT → UUID | 050_legacy_chat.sql | ✅ Remplacé |
| 042_create_room_members.sql | room_members | INT → UUID | 050_legacy_chat.sql | ✅ Remplacé |
| 043_create_messages.sql | messages | INT → UUID | 050_legacy_chat.sql | ✅ Remplacé |
| 044_add_sessions_revoked_at.sql | sessions | - | 010_auth_and_users.sql | ✅ Remplacé |
| 045_create_user_sessions.sql | user_sessions | INT → UUID | 010_auth_and_users.sql | ✅ Remplacé |
| 046_add_playlists_missing_columns.sql | playlists | - | 040_streaming_core.sql | ✅ Remplacé |
| 047_migrate_users_id_to_uuid.sql | users | Migration INT→UUID | - | ✅ Migration appliquée |
| 048_migrate_webhooks_to_uuid.sql | webhooks | Migration INT→UUID | - | ✅ Migration appliquée |
| 049_migrate_sessions_to_uuid.sql | sessions | Migration INT→UUID | - | ✅ Migration appliquée |
| 050_migrate_room_members_to_uuid.sql | room_members | Migration INT→UUID | - | ✅ Migration appliquée |
| 051_migrate_messages_to_uuid.sql | messages | Migration INT→UUID | - | ✅ Migration appliquée |
| 060_migrate_tracks_playlists_to_uuid.sql | tracks, playlists | Migration INT→UUID | - | ✅ Migration appliquée |
| 061_migrate_admin_tables_to_uuid.sql | admin tables | Migration INT→UUID | - | ✅ Migration appliquée |
| 062_migrate_roles_permissions_to_uuid.sql | roles, permissions | Migration INT→UUID | - | ✅ Migration appliquée |
| 070_finish_secondary_tables_uuid.sql | secondary tables | Migration INT→UUID | - | ✅ Migration appliquée |
| 070_fix_users_user_roles_uuid.sql | user_roles | Migration INT→UUID | - | ✅ Migration appliquée |
| 071_migrate_tracks_playlists_pk_to_uuid.sql | tracks, playlists | Migration PK INT→UUID | - | ✅ Migration appliquée |
| 072_create_chat_schema.sql | chat tables | UUID | 050_legacy_chat.sql | ✅ Remplacé |
| XXX_create_playlist_versions.sql | playlist_versions | INT → UUID | 040_streaming_core.sql | ✅ Remplacé |
Total : 44 fichiers legacy à supprimer
veza-chat-server/migrations/ (MODERN - UUID)
| Fichier | Tables impactées | Type d'ID | Notes |
|---|---|---|---|
| 001_create_clean_database.sql | users, conversations, messages | UUID | ✅ Toutes les tables utilisent UUID |
| 002_advanced_features.sql | messages, conversations | UUID | ✅ |
| 1000_dm_enriched.sql | conversations | UUID | ✅ |
| 1001_post_migration_fixes.sql | - | - | Corrections |
| 999_cleanup_production_ready_fixed.sql | - | - | Nettoyage |
| archive/ | 4 fichiers archivés | - | Archive (peut être supprimé) |
Total : 5 fichiers actifs + 4 archivés
veza-stream-server/migrations/
Aucun fichier de migration SQL - Le stream-server n'utilise pas de migrations SQL explicites.
2. Modèles et types d'ID par service
2.1 veza-backend-api (Go)
| Modèle | Fichier | Type ID actuel | Type ID attendu | Conforme | Notes |
|---|---|---|---|---|---|
| User | internal/models/user.go | uuid.UUID | uuid.UUID | ✅ | |
| Track | internal/models/track.go | uuid.UUID | uuid.UUID | ✅ | |
| Playlist | internal/models/playlist.go | uuid.UUID | uuid.UUID | ✅ | |
| Session | internal/models/session.go | uuid.UUID | uuid.UUID | ✅ | |
| Room | internal/models/room.go | uuid.UUID | uuid.UUID | ✅ | |
| Message | internal/models/message.go | uuid.UUID | uuid.UUID | ✅ | |
| Role | internal/models/role.go | uuid.UUID | uuid.UUID | ✅ | |
| RefreshToken | internal/models/refresh_token.go | uuid.UUID | uuid.UUID | ✅ | |
| TrackLike | internal/models/track_like.go | uuid.UUID | uuid.UUID | ✅ | |
| TrackComment | internal/models/track_comment.go | uuid.UUID | uuid.UUID | ✅ | |
| TrackShare | internal/models/track_share.go | uuid.UUID | uuid.UUID | ✅ | |
| PlaylistCollaborator | internal/models/playlist_collaborator.go | uuid.UUID | uuid.UUID | ✅ | |
| PlaybackAnalytics | internal/models/playback_analytics.go | uuid.UUID | uuid.UUID | ✅ | |
| HLSStream | internal/models/hls_stream.go | uuid.UUID | uuid.UUID | ✅ | |
| HLSTranscodeQueue | internal/models/hls_transcode_queue.go | uuid.UUID | uuid.UUID | ✅ | |
| Contest | internal/models/contest.go | uuid.UUID | uuid.UUID | ✅ | |
| ContestEntry | internal/models/contest.go | uuid.UUID | uuid.UUID | ✅ | |
| MFAConfig | internal/models/mfa_config.go | uuid.UUID | uuid.UUID | ✅ | |
| FederatedIdentity | internal/models/federated_identity.go | uuid.UUID | uuid.UUID | ✅ | |
| AdminSettings | internal/models/admin.go | uuid.UUID | uuid.UUID | ✅ | |
| AuditLog | internal/models/admin.go | uuid.UUID | uuid.UUID | ✅ | |
| CategoryStats | internal/models/admin.go | int | int | ✅ | Compteur, pas un ID |
Résultat : ✅ 100% conforme - Tous les modèles principaux utilisent UUID
2.2 veza-chat-server (Rust)
| Struct | Fichier | Type ID | Type UUID | Conforme | Notes |
|---|---|---|---|---|---|
| Message | src/models/message.rs | Uuid | ✅ | ✅ | ID principal = UUID |
| Room (channels.rs) | src/hub/channels.rs | id: i64, uuid: Uuid | ⚠️ | ❌ | PROBLÈME : Double ID (i64 + UUID) |
| RoomMember | src/hub/channels.rs | id: i64, conversation_id: i64, user_id: i64 | ❌ | ❌ | PROBLÈME : Utilise i64 |
| RoomMessage | src/hub/channels.rs | id: i64, uuid: Uuid, author_id: i64 | ⚠️ | ❌ | PROBLÈME : Mixte |
| Conversation (DB) | migrations/001_create_clean_database.sql | UUID | ✅ | ✅ | Schéma DB = UUID |
Résultat : ⚠️ Partiellement conforme - Le schéma DB utilise UUID, mais le code Rust utilise encore des i64 pour certains IDs.
Problème identifié : Le chat-server a une cohabitation INT/UUID :
- Les structures Rust (
Room,RoomMember,RoomMessage) utilisenti64pour les IDs - La base de données utilise
UUID(voirmigrations/001_create_clean_database.sql) - Il y a un champ
uuid: Uuiddans certaines structures mais l'ID principal restei64
2.3 veza-stream-server (Rust)
À vérifier : Le stream-server n'a pas de modèles de données explicites dans le code analysé. Il semble utiliser des UUIDs pour les identifiants de tracks (basé sur les appels API).
2.4 apps/web (Frontend React)
| Interface/Type | Fichier | Type ID | Conforme | Notes |
|---|---|---|---|---|
| User | src/types/user.ts (présumé) | string (uuid) | ✅ | Les UUIDs sont représentés comme strings en TS |
| Track | src/types/track.ts (présumé) | string (uuid) | ✅ | |
| Playlist | src/types/playlist.ts (présumé) | string (uuid) | ✅ |
Résultat : ✅ Conforme - Le frontend traite les IDs comme des strings (format UUID)
3. Code legacy détecté
3.1 Fichiers explicitement legacy (à supprimer)
| Fichier/Dossier | Service | Raison | Vérification |
|---|---|---|---|
migrations_legacy/ (44 fichiers) |
veza-backend-api | Dossier entier legacy, remplacé par migrations/ |
✅ Aucun import référencé |
cmd/main.go.legacy |
veza-backend-api | Ancien point d'entrée | ✅ Non référencé dans build |
migrations/archive/ (4 fichiers) |
veza-chat-server | Fichiers archivés | ⚠️ À vérifier si utilisés |
3.2 Code avec patterns INT (à vérifier/migrer)
Backend Go
| Fichier | Ligne | Code | Action | Priorité |
|---|---|---|---|---|
internal/core/track/handler.go |
136 | // TODO(P2-GO-004): trackUploadService attend int64 |
Vérifier si trackUploadService utilise encore int64 | 🔴 Haute |
internal/core/track/handler.go |
151 | // TODO(P2-GO-004): Migration UUID partielle |
Compléter migration trackUploadService | 🔴 Haute |
internal/services/track_history_service.go |
81 | // FIXME: models.TrackHistory needs UUID too |
Vérifier TrackHistory | 🟡 Moyenne |
internal/repositories/playlist_collaborator_repository.go |
67 | // FIXME: Assurer que le modèle PlaylistCollaborator utilise UUID |
Vérifier (déjà UUID normalement) | 🟢 Basse |
internal/services/playlist_version_service.go |
72 | // FIXME: models.PlaylistVersion ID types need check |
Vérifier PlaylistVersion | 🟡 Moyenne |
internal/services/playlist_service.go |
212 | // FIXME: PlaylistVersionService likely needs update |
Vérifier PlaylistVersionService | 🟡 Moyenne |
Chat Server Rust
| Fichier | Ligne | Code | Action | Priorité |
|---|---|---|---|---|
src/hub/channels.rs |
28-40 | pub struct Room { pub id: i64, pub uuid: Uuid, ... } |
Migrer vers UUID uniquement | 🔴 Haute |
src/hub/channels.rs |
42-51 | pub struct RoomMember { pub id: i64, pub conversation_id: i64, ... } |
Migrer vers UUID | 🔴 Haute |
src/hub/channels.rs |
54-75 | pub struct RoomMessage { pub id: i64, pub uuid: Uuid, ... } |
Migrer vers UUID uniquement | 🔴 Haute |
src/hub/channels.rs |
98-165 | Fonctions utilisant i64 pour room_id, user_id |
Migrer vers UUID | 🔴 Haute |
Problème majeur : Le chat-server Rust utilise des i64 alors que la DB utilise UUID. Il faut soit :
- Migrer le code Rust vers UUID (recommandé)
- Ou créer une couche de conversion (non recommandé)
3.3 TODOs liés à la migration
| Fichier | Ligne | TODO | Statut | Action |
|---|---|---|---|---|
internal/core/track/handler.go |
136 | TODO(P2-GO-004): trackUploadService attend int64 |
⚠️ À vérifier | Vérifier trackUploadService |
internal/core/track/handler.go |
151 | TODO(P2-GO-004): Migration UUID partielle |
⚠️ À vérifier | Compléter migration |
internal/services/track_history_service.go |
81 | FIXME: models.TrackHistory needs UUID too |
⚠️ À vérifier | Vérifier TrackHistory |
internal/repositories/playlist_collaborator_repository.go |
67 | FIXME: Assurer que le modèle PlaylistCollaborator utilise UUID |
✅ Probablement fait | Vérifier et supprimer si OK |
internal/services/playlist_version_service.go |
72 | FIXME: models.PlaylistVersion ID types need check |
⚠️ À vérifier | Vérifier PlaylistVersion |
internal/services/playlist_service.go |
212 | FIXME: PlaylistVersionService likely needs update |
⚠️ À vérifier | Vérifier PlaylistVersionService |
4. Foreign Keys et cohérence
4.1 Backend Go
| Table source | Colonne FK | Table cible | Type FK | Type PK cible | Cohérent |
|---|---|---|---|---|---|
| tracks | user_id | users | UUID | UUID | ✅ |
| playlists | user_id | users | UUID | UUID | ✅ |
| track_likes | track_id | tracks | UUID | UUID | ✅ |
| track_likes | user_id | users | UUID | UUID | ✅ |
| track_comments | track_id | tracks | UUID | UUID | ✅ |
| track_comments | user_id | users | UUID | UUID | ✅ |
| playlist_collaborators | playlist_id | playlists | UUID | UUID | ✅ |
| playlist_collaborators | user_id | users | UUID | UUID | ✅ |
| room_members | room_id | rooms | UUID | UUID | ✅ |
| room_members | user_id | users | UUID | UUID | ✅ |
| messages | room_id | rooms | UUID | UUID | ✅ |
| messages | user_id | users | UUID | UUID | ✅ |
| sessions | user_id | users | UUID | UUID | ✅ |
| refresh_tokens | user_id | users | UUID | UUID | ✅ |
Résultat : ✅ 100% cohérent - Toutes les Foreign Keys utilisent UUID
4.2 Chat Server (Base de données)
| Table source | Colonne FK | Table cible | Type FK | Type PK cible | Cohérent |
|---|---|---|---|---|---|
| conversations | created_by | users | UUID | UUID | ✅ |
| conversation_members | conversation_id | conversations | UUID | UUID | ✅ |
| conversation_members | user_id | users | UUID | UUID | ✅ |
| messages | conversation_id | conversations | UUID | UUID | ✅ |
| messages | sender_id | users | UUID | UUID | ✅ |
| messages | parent_message_id | messages | UUID | UUID | ✅ |
Résultat : ✅ 100% cohérent - Le schéma DB utilise UUID partout
Problème : Le code Rust utilise i64 alors que la DB utilise UUID → Incohérence code/DB
5. Endpoints et parsing d'ID
5.1 Backend Go - Endpoints analysés
| Endpoint | Service | Fichier | Méthode de parsing | Format attendu | Conforme |
|---|---|---|---|---|---|
| GET /api/v1/users/:id | backend-api | handlers/profile_handler.go | uuid.Parse(id) |
UUID | ✅ |
| GET /api/v1/tracks/:id | backend-api | internal/core/track/handler.go | uuid.Parse(id) |
UUID | ✅ |
| PUT /api/v1/tracks/:id | backend-api | internal/core/track/handler.go | uuid.Parse(id) |
UUID | ✅ |
| DELETE /api/v1/tracks/:id | backend-api | internal/core/track/handler.go | uuid.Parse(id) |
UUID | ✅ |
| GET /api/v1/tracks/:id/bitrate/analytics | backend-api | handlers/bitrate_handler.go | uuid.Parse(id) |
UUID | ✅ |
| POST /api/v1/tracks/:id/analytics | backend-api | handlers/playback_analytics_handler.go | uuid.Parse(id) |
UUID | ✅ |
| POST /api/v1/tracks/:id/hls/transcode | backend-api | handlers/hls_handler.go | uuid.Parse(id) |
UUID | ✅ |
| GET /api/v1/playlists/:id | backend-api | handlers/playlist_handler.go | uuid.Parse(id) |
UUID | ✅ |
Résultat : ✅ 100% conforme - Tous les endpoints utilisent uuid.Parse()
5.2 Patterns de parsing détectés
Patterns UUID (corrects) :
trackID, err := uuid.Parse(c.Param("id"))
Patterns INT (legacy - non trouvés dans les handlers actifs) :
// Aucun strconv.Atoi trouvé pour les IDs dans les handlers
// Seulement pour pagination (page, limit) - OK
Résultat : ✅ Aucun pattern INT détecté pour les IDs dans les handlers
6. Dépendances inter-services
6.1 Communication inter-services
| Service source | Service cible | Méthode | Format ID échangé | Cohérent | Notes |
|---|---|---|---|---|---|
| backend-api | chat-server | HTTP/WebSocket | UUID (string) | ✅ | Via API REST |
| backend-api | stream-server | HTTP | UUID (string) | ✅ | Via API REST |
| web frontend | backend-api | REST | string (uuid) | ✅ | JSON serialization |
| mobile | backend-api | REST | string (uuid) | ✅ | JSON serialization |
| desktop | backend-api | REST | string (uuid) | ✅ | JSON serialization |
Résultat : ✅ Cohérent - Tous les échanges utilisent UUID (sérialisés en string)
6.2 DTOs et contrats
Backend → Frontend
| DTO | Fichier | Champ ID | Type | Frontend attend | Conforme |
|---|---|---|---|---|---|
| UserResponse | internal/api/user/types.go | ID | uuid.UUID | string | ✅ |
| TrackResponse | internal/core/track/handler.go | ID | uuid.UUID | string | ✅ |
| PlaylistResponse | handlers/playlist_handler.go | ID | uuid.UUID | string | ✅ |
Résultat : ✅ Conforme - Les UUIDs sont sérialisés en string JSON (comportement standard)
7. Plan de nettoyage
7.1 Inventaire des suppressions
Suppressions sûres (aucune dépendance)
| Chemin | Raison | Vérification | Taille estimée |
|---|---|---|---|
veza-backend-api/migrations_legacy/ |
Remplacé par migrations/ |
✅ Aucun import | ~44 fichiers |
veza-backend-api/cmd/main.go.legacy |
Ancien point d'entrée | ✅ Non référencé | 1 fichier |
veza-chat-server/migrations/archive/ |
Fichiers archivés | ⚠️ À vérifier | 4 fichiers |
Total : ~49 fichiers à supprimer
Suppressions à valider (peuvent avoir des dépendances)
| Chemin | Raison | Dépendances à vérifier |
|---|---|---|
| Aucun identifié | - | - |
7.2 Modifications de code nécessaires
Haute priorité (bloque la suppression legacy)
| Fichier | Ligne | Modification | Avant | Après | Service |
|---|---|---|---|---|---|
src/hub/channels.rs |
28-40 | Migrer Room.id vers UUID | pub id: i64 |
pub id: Uuid |
chat-server |
src/hub/channels.rs |
42-51 | Migrer RoomMember vers UUID | pub id: i64, pub conversation_id: i64, pub user_id: i64 |
pub id: Uuid, pub conversation_id: Uuid, pub user_id: Uuid |
chat-server |
src/hub/channels.rs |
54-75 | Migrer RoomMessage vers UUID | pub id: i64, pub author_id: i64, ... |
pub id: Uuid, pub author_id: Uuid, ... |
chat-server |
src/hub/channels.rs |
Toutes fonctions | Migrer signatures vers UUID | room_id: i64, user_id: i64 |
room_id: Uuid, user_id: Uuid |
chat-server |
Estimation : 2-3 heures pour migrer le chat-server Rust
Moyenne priorité (nettoyage)
| Fichier | Modification | Raison |
|---|---|---|
internal/core/track/handler.go |
Vérifier et supprimer TODOs si résolus | Nettoyage |
internal/services/track_history_service.go |
Vérifier TrackHistory.ID | Vérification |
internal/services/playlist_version_service.go |
Vérifier PlaylistVersion.ID | Vérification |
internal/services/playlist_service.go |
Vérifier et supprimer FIXME si résolu | Nettoyage |
internal/repositories/playlist_collaborator_repository.go |
Vérifier et supprimer FIXME si résolu | Nettoyage |
Estimation : 30 minutes - 1 heure
Basse priorité (cosmétique)
| Fichier | Modification |
|---|---|
Tous les fichiers avec commentaires MIGRATION UUID: ... |
Supprimer commentaires obsolètes |
| Documentation | Mettre à jour pour refléter UUID partout |
Estimation : 30 minutes
7.3 Ordre des opérations recommandé
Étape 1 : Préparation (avant toute suppression)
- Créer une branche
cleanup/uuid-migration - S'assurer que tous les tests passent sur main
- Tag git :
git tag pre-uuid-cleanup - Backup :
tar -czf migrations_legacy_backup.tar.gz veza-backend-api/migrations_legacy/
Étape 2 : Corrections de code (dans l'ordre)
2.1 Chat Server Rust (priorité haute)
- Migrer
src/hub/channels.rs:Room.idversUuid - Migrer
src/hub/channels.rs:RoomMemberversUuid - Migrer
src/hub/channels.rs:RoomMessageversUuid - Migrer toutes les fonctions dans
channels.rsvers UUID - Vérifier tous les autres fichiers Rust du chat-server
- Compiler :
cd veza-chat-server && cargo build --release - Tests :
cd veza-chat-server && cargo test
2.2 Backend Go (vérifications)
- Vérifier
internal/services/track_upload_service.go: utilise-t-il UUID ? - Vérifier
internal/models/track_history.go: ID est-il UUID ? - Vérifier
internal/models/playlist_version.go: ID est-il UUID ? - Supprimer les TODOs/FIXMEs résolus
- Tests :
cd veza-backend-api && go test ./... -v
Étape 3 : Suppressions (dans l'ordre)
- Supprimer
veza-backend-api/migrations_legacy/rm -rf veza-backend-api/migrations_legacy/ - Supprimer
veza-backend-api/cmd/main.go.legacyrm veza-backend-api/cmd/main.go.legacy - Vérifier et supprimer
veza-chat-server/migrations/archive/(si non utilisé)# Vérifier d'abord cd veza-chat-server && cargo build # Si OK, supprimer rm -rf veza-chat-server/migrations/archive/ - Lancer les tests → doivent passer
cd veza-backend-api && go test ./... -v cd veza-chat-server && cargo test
Étape 4 : Nettoyage final
- Supprimer TODOs obsolètes liés à la migration
- Supprimer commentaires
MIGRATION UUID: ...obsolètes - Mettre à jour la documentation
- Commit final avec message explicite
Étape 5 : Validation
- Build complet de tous les services
cd veza-backend-api && go build ./cmd/api cd veza-chat-server && cargo build --release cd veza-stream-server && cargo build --release cd apps/web && npm run build - Tests complets
cd veza-backend-api && go test ./... -v cd veza-chat-server && cargo test - Review du diff total
git diff pre-uuid-cleanup..HEAD --stat
7.4 Script de nettoyage
#!/bin/bash
# cleanup-uuid-migration.sh
# À exécuter depuis la racine du monorepo
set -e # Stop on error
echo "=== Étape 1: Vérification pré-cleanup ==="
# Vérifier qu'on est sur la bonne branche
CURRENT_BRANCH=$(git branch --show-current)
if [ "$CURRENT_BRANCH" != "cleanup/uuid-migration" ]; then
echo "⚠️ Vous n'êtes pas sur la branche cleanup/uuid-migration"
echo "Création de la branche..."
git checkout -b cleanup/uuid-cleanup
fi
# Vérifier que les tests passent
echo "🧪 Vérification des tests..."
cd veza-backend-api && go test ./... -v || { echo "❌ Tests backend échoués"; exit 1; }
cd ../veza-chat-server && cargo test || { echo "❌ Tests chat-server échoués"; exit 1; }
cd ..
echo "✅ Tests OK"
echo ""
echo "=== Étape 2: Backup ==="
BACKUP_DIR="backup-pre-cleanup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$BACKUP_DIR"
echo "📦 Création du backup dans $BACKUP_DIR..."
tar -czf "$BACKUP_DIR/migrations_legacy.tar.gz" veza-backend-api/migrations_legacy/ 2>/dev/null || echo "⚠️ migrations_legacy/ déjà supprimé ou inexistant"
cp veza-backend-api/cmd/main.go.legacy "$BACKUP_DIR/" 2>/dev/null || echo "⚠️ main.go.legacy déjà supprimé ou inexistant"
echo "✅ Backup créé"
echo ""
echo "=== Étape 3: Suppressions ==="
# Supprimer migrations_legacy
if [ -d "veza-backend-api/migrations_legacy" ]; then
echo "🗑️ Suppression de veza-backend-api/migrations_legacy/..."
rm -rf veza-backend-api/migrations_legacy/
echo "✅ Supprimé"
else
echo "ℹ️ migrations_legacy/ n'existe pas (déjà supprimé ?)"
fi
# Supprimer main.go.legacy
if [ -f "veza-backend-api/cmd/main.go.legacy" ]; then
echo "🗑️ Suppression de veza-backend-api/cmd/main.go.legacy..."
rm veza-backend-api/cmd/main.go.legacy
echo "✅ Supprimé"
else
echo "ℹ️ main.go.legacy n'existe pas (déjà supprimé ?)"
fi
# Supprimer archive (optionnel, après vérification)
if [ -d "veza-chat-server/migrations/archive" ]; then
echo "⚠️ veza-chat-server/migrations/archive/ existe"
echo "Vérifiez manuellement s'il peut être supprimé"
# rm -rf veza-chat-server/migrations/archive/
fi
echo ""
echo "=== Étape 4: Vérification post-cleanup ==="
# Build
echo "🔨 Build backend..."
cd veza-backend-api && go build ./cmd/api || { echo "❌ Build backend échoué"; exit 1; }
cd ..
echo "🔨 Build chat-server..."
cd veza-chat-server && cargo build --release || { echo "❌ Build chat-server échoué"; exit 1; }
cd ..
# Tests
echo "🧪 Tests backend..."
cd veza-backend-api && go test ./... -v || { echo "❌ Tests backend échoués"; exit 1; }
cd ..
echo "🧪 Tests chat-server..."
cd veza-chat-server && cargo test || { echo "❌ Tests chat-server échoués"; exit 1; }
cd ..
echo ""
echo "=== ✅ Cleanup terminé ==="
echo ""
echo "📊 Résumé :"
echo " - Backup créé dans : $BACKUP_DIR"
echo " - migrations_legacy/ : Supprimé"
echo " - main.go.legacy : Supprimé"
echo ""
echo "📝 Prochaines étapes :"
echo " 1. Review les changements : git diff"
echo " 2. Commit : git commit -m 'chore: remove legacy UUID migration files'"
echo " 3. Push : git push origin cleanup/uuid-migration"
Utilisation :
chmod +x cleanup-uuid-migration.sh
./cleanup-uuid-migration.sh
8. Documentation à mettre à jour
8.1 Fichiers à mettre à jour
| Fichier | Section | Modification |
|---|---|---|
README.md |
Setup | Supprimer références aux anciennes migrations |
CONTRIBUTING.md |
Guidelines | Ajouter : "Tous les IDs sont des UUID v4" |
veza-backend-api/README.md |
Database | Confirmer UUID partout |
veza-chat-server/README.md |
Database | Confirmer UUID partout |
8.2 Nouveau contenu à ajouter
Dans README.md ou CONTRIBUTING.md :
## Identifiants (IDs)
**Tous les IDs dans Veza sont des UUID v4.**
- ✅ **À faire** : Utiliser `uuid.UUID` (Go) ou `Uuid` (Rust) pour tous les IDs
- ❌ **À éviter** : Ne jamais utiliser d'ID entiers (`int`, `int64`, `i64`) pour les identifiants
- ✅ **Frontend** : Les UUIDs sont représentés comme des strings en TypeScript/JavaScript
- ✅ **API** : Les UUIDs sont sérialisés en string dans les réponses JSON
### Exemples
**Go** :
```go
type User struct {
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
}
Rust :
pub struct User {
pub id: Uuid,
}
TypeScript :
interface User {
id: string; // UUID format
}
---
## 9. Checklist finale
### Avant le nettoyage
- [ ] Tous les modèles utilisent `uuid.UUID` (Go) ou `Uuid` (Rust)
- [ ] Aucun `strconv.Atoi` pour les IDs dans les handlers
- [ ] Tous les endpoints utilisent `uuid.Parse()` pour les IDs
- [ ] Tous les tests passent
- [ ] Backup créé
### Après le nettoyage
- [ ] `migrations_legacy/` supprimé
- [ ] `*.legacy` fichiers supprimés
- [ ] Aucun fichier `*.legacy` restant
- [ ] Chat-server Rust migré vers UUID (si applicable)
- [ ] Documentation à jour
- [ ] Tests passent
- [ ] Build OK pour tous les services
- [ ] Commit avec message explicite
- [ ] Tag post-cleanup créé
---
## 10. Risques et précautions
### Risques identifiés
1. **Chat-server Rust** : Migration de `i64` vers `Uuid` peut casser des intégrations
- **Mitigation** : Tester exhaustivement avant merge
- **Rollback** : Tag git `pre-uuid-cleanup` permet rollback
2. **Services dépendants** : Si d'autres services consomment les APIs avec format INT
- **Mitigation** : Vérifier les contrats d'API avant suppression
- **Vérification** : Aucun service externe identifié utilisant INT
3. **Base de données** : Les migrations legacy peuvent être référencées dans la doc
- **Mitigation** : Mettre à jour la documentation
### Précautions
- ✅ **Toujours pouvoir rollback** : Tag git `pre-uuid-cleanup`
- ✅ **Un service à la fois** : Ne pas tout casser en même temps
- ✅ **Tests entre chaque étape** : Valider que rien n'est cassé
- ✅ **Le frontend doit continuer à fonctionner** : Vérifier que les types correspondent
---
## 11. Conclusion
La migration UUID est **largement complétée** dans le monorepo Veza :
✅ **Backend Go** : 100% migré vers UUID
⚠️ **Chat Server Rust** : Schéma DB = UUID, mais code Rust utilise encore `i64` (à migrer)
✅ **Frontend** : Utilise string (UUID) - conforme
✅ **Inter-services** : Communication en UUID - conforme
**Actions prioritaires** :
1. 🔴 **Haute** : Migrer le chat-server Rust vers UUID (2-3h)
2. 🟡 **Moyenne** : Supprimer `migrations_legacy/` et fichiers `.legacy` (30min)
3. 🟢 **Basse** : Nettoyer les TODOs/FIXMEs et documentation (30min)
**Estimation totale** : 4-6 heures pour un nettoyage complet.
---
**Document généré le** : 2025-01-27
**Prochaine révision** : Après nettoyage complet