Livraison d ela gestion des opérations v0.4.0
This commit is contained in:
26
api/migration_add_file_category.sql
Normal file
26
api/migration_add_file_category.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- Migration pour ajouter la colonne file_category à la table medias
|
||||
-- Date: 2025-06-22
|
||||
-- Description: Ajout du champ file_category pour distinguer les types métier des fichiers
|
||||
|
||||
-- Ajout de la colonne file_category
|
||||
ALTER TABLE `medias`
|
||||
ADD COLUMN `file_category` varchar(50) DEFAULT NULL COMMENT 'Catégorie du fichier (logo, carte, photo, document, etc.)' AFTER `file_type`;
|
||||
|
||||
-- Ajout de l'index pour optimiser les requêtes
|
||||
ALTER TABLE `medias`
|
||||
ADD INDEX `idx_file_category` (`file_category`);
|
||||
|
||||
-- Mise à jour des données existantes avec des catégories par défaut selon le support
|
||||
UPDATE `medias` SET `file_category` = 'document' WHERE `support` = 'entite' AND `file_category` IS NULL;
|
||||
UPDATE `medias` SET `file_category` = 'avatar' WHERE `support` = 'user' AND `file_category` IS NULL;
|
||||
UPDATE `medias` SET `file_category` = 'export' WHERE `support` = 'operation' AND `file_category` IS NULL;
|
||||
UPDATE `medias` SET `file_category` = 'recu' WHERE `support` = 'passage' AND `file_category` IS NULL;
|
||||
|
||||
-- Vérification des modifications
|
||||
SELECT
|
||||
support,
|
||||
file_category,
|
||||
COUNT(*) as count
|
||||
FROM medias
|
||||
GROUP BY support, file_category
|
||||
ORDER BY support, file_category;
|
||||
Reference in New Issue
Block a user