DELETE FROM f_adr WHERE 1 = 1;
DELETE FROM f_badge WHERE 1 = 1;
DELETE FROM f_badge_message WHERE 1 = 1;
DELETE FROM f_config WHERE x_poste != 'TOUS';
DELETE FROM f_dest WHERE x_dest != 'ECO-TEST';
DELETE FROM f_espace WHERE 1 = 1;
DELETE FROM f_gpao WHERE 1 = 1;
DELETE FROM f_histo WHERE 1 = 1;
DELETE FROM f_histo_blocage WHERE 1 = 1;
DELETE FROM f_histo_coupe WHERE 1 = 1;
DELETE FROM f_histo_identification WHERE 1 = 1;
DELETE FROM f_histo_pilulier WHERE 1 = 1;
DELETE FROM f_histo_plateau WHERE 1 = 1;
DELETE FROM f_histo_sachet WHERE 1 = 1;
DELETE FROM f_item WHERE 1 = 1;
DELETE FROM f_liste WHERE 1 = 1;
DELETE FROM f_item_valide WHERE 1 = 1;
DELETE FROM f_item_w WHERE 1 = 1;
DELETE FROM f_liste_valide WHERE 1 = 1;
DELETE FROM f_log_defaut WHERE 1 = 1;
DELETE FROM f_log_echange_automate WHERE 1 = 1;
DELETE FROM f_log_astus WHERE 1 = 1;
DELETE FROM f_lot_retire WHERE 1 = 1;
DELETE FROM f_mag WHERE 1 = 1;
DELETE FROM f_mag_dest WHERE 1 = 1;
DELETE FROM f_mag_groupe WHERE 1 = 1;
DELETE FROM f_message_astus WHERE 1 = 1;
DELETE FROM f_patient WHERE 1 = 1;
DELETE FROM f_poste WHERE x_poste != 'SERVEUR';
DELETE FROM f_prescription WHERE 1 = 1;
DELETE FROM f_ref WHERE 1 = 1;
DELETE FROM f_ref_ucd WHERE 1 = 1;
DELETE FROM f_ucd_cip WHERE 1 = 1;
DELETE FROM f_robot WHERE 1 = 1;
DELETE FROM f_sachet WHERE 1 = 1;
DELETE FROM f_sejour WHERE 1 = 1;
DELETE FROM f_seuil WHERE 1 = 1;
DELETE FROM f_stock WHERE 1 = 1;
DELETE FROM f_user WHERE x_profil NOT IN ('ECO-DEX', 'ADMIN', 'DEENOVA');
DELETE FROM f_wsclient_erreur WHERE 1 = 1;
DELETE FROM f_zone WHERE 1 = 1;
DELETE FROM f_zonemag WHERE 1 = 1;

-- RESET COUNTER
UPDATE `median`.`f_compteur` SET `x_val`=1 WHERE x_cle = 'CONTENANT_PASS';
UPDATE `median`.`f_compteur` SET `x_val`=1 WHERE x_cle = 'ID_DECOUPE';
UPDATE `median`.`f_compteur` SET `x_val`=1 WHERE x_cle = 'ID_CHARGEMENT_ST1';
UPDATE `median`.`f_compteur` SET `x_val`=1 WHERE x_cle = 'ID_PILULIER_ST1';
UPDATE `median`.`f_compteur` SET `x_val`=1 WHERE x_cle = 'ID_PLATEAU_ST1';
UPDATE `median`.`f_compteur` SET `x_val`=50000000 WHERE x_cle = 'ID_CHARGEMENT_ST2';
UPDATE `median`.`f_compteur` SET `x_val`=50000000 WHERE x_cle = 'ID_PILULIER_ST2';
UPDATE `median`.`f_compteur` SET `x_val`=50000000 WHERE x_cle = 'ID_PLATEAU_ST2';
UPDATE `median`.`f_compteur` SET `x_val`=1 WHERE x_cle = 'WS_COMPTEUR';
UPDATE `median`.`f_compteur` SET `x_val`=1 WHERE x_cle = 'RIEDL_ORDERCODE';
UPDATE `median`.`f_compteur` SET `x_val`=1 WHERE x_cle = 'RIEDL_RETOUR';
UPDATE `median`.`f_compteur` SET `x_val`=1 WHERE x_cle = 'RIEDL_PRELEVEMENT';
UPDATE `median`.`f_compteur` SET `x_val`=1 WHERE x_cle = 'RIEDL_GLOBALE';


ALTER TABLE f_adr AUTO_INCREMENT=1;
ALTER TABLE f_badge AUTO_INCREMENT=1;
ALTER TABLE f_badge_message AUTO_INCREMENT=1;
ALTER TABLE f_espace AUTO_INCREMENT=1;
ALTER TABLE f_gpao AUTO_INCREMENT=1;
ALTER TABLE f_histo AUTO_INCREMENT=1;
ALTER TABLE f_histo_blocage AUTO_INCREMENT=1;
ALTER TABLE f_histo_coupe AUTO_INCREMENT=1;
ALTER TABLE f_histo_identification AUTO_INCREMENT=1;
ALTER TABLE f_histo_pilulier AUTO_INCREMENT=1;
ALTER TABLE f_histo_plateau AUTO_INCREMENT=1;
ALTER TABLE f_histo_sachet AUTO_INCREMENT=1;
ALTER TABLE f_item AUTO_INCREMENT=1;
ALTER TABLE f_liste AUTO_INCREMENT=1;
ALTER TABLE f_item_valide AUTO_INCREMENT=1;
ALTER TABLE f_liste_valide AUTO_INCREMENT=1;
ALTER TABLE f_item_w AUTO_INCREMENT=1;
ALTER TABLE f_log_defaut AUTO_INCREMENT=1;
ALTER TABLE f_log_echange_automate AUTO_INCREMENT=1;
ALTER TABLE f_patient AUTO_INCREMENT=1;
ALTER TABLE f_prescription AUTO_INCREMENT=1;
ALTER TABLE f_ref AUTO_INCREMENT=1;
ALTER TABLE f_ref_ucd AUTO_INCREMENT=1;
ALTER TABLE f_ucd_cip AUTO_INCREMENT=1;
ALTER TABLE f_robot AUTO_INCREMENT=1;
ALTER TABLE f_sachet AUTO_INCREMENT=1;
ALTER TABLE f_sejour AUTO_INCREMENT=1;
ALTER TABLE f_seuil AUTO_INCREMENT=1;
ALTER TABLE f_stock AUTO_INCREMENT=1;
ALTER TABLE f_wsclient_erreur AUTO_INCREMENT=1;
ALTER TABLE f_zone AUTO_INCREMENT=1;
ALTER TABLE f_zonemag AUTO_INCREMENT=1;

-- ANAlyse and Optimize (Index and table size)
ANALYZE TABLE f_adr;
ANALYZE TABLE f_stock;
ANALYZE TABLE f_badge;

OPTIMIZE TABLE `f_badges`;
OPTIMIZE TABLE `f_badge_message`;
OPTIMIZE TABLE `f_espace`;
OPTIMIZE TABLE `f_gpao`;
OPTIMIZE TABLE `f_histo`;
OPTIMIZE TABLE `f_histo_blocage`;
OPTIMIZE TABLE `f_histo_identification`;
OPTIMIZE TABLE `f_histo_pilulier`;
OPTIMIZE TABLE `f_histo_plateau`;
OPTIMIZE TABLE `f_histo_sachet`;
OPTIMIZE TABLE `f_item`;
OPTIMIZE TABLE `f_liste`;
OPTIMIZE TABLE `f_item_valide`;
OPTIMIZE TABLE `f_liste_valide`;
OPTIMIZE TABLE `f_item_w`;
OPTIMIZE TABLE `f_log_defaut`;
OPTIMIZE TABLE `f_log_echange_automate`;
OPTIMIZE TABLE `f_ref`;
OPTIMIZE TABLE `f_ref_ucd`;
OPTIMIZE TABLE `f_ucd_cip`;
OPTIMIZE TABLE `f_robot`;
OPTIMIZE TABLE `f_sachet`;
OPTIMIZE TABLE `f_sejour`;
OPTIMIZE TABLE `f_seuil`;
OPTIMIZE TABLE `f_stock`;
OPTIMIZE TABLE `f_wsclient_erreur`;
OPTIMIZE TABLE `f_zone`;
OPTIMIZE TABLE `f_zonemag`;

-- Nettoyage token de monitoring
UPDATE f_config SET x_val = '' WHERE x_poste = 'TOUS' AND x_prop = 'k_eco_monitoring_token';
UPDATE f_config SET x_val = '0' WHERE x_poste = 'TOUS' AND x_prop = 'k_eco_monitoring_proxy';
UPDATE f_config SET x_val = '' WHERE x_poste = 'TOUS' AND x_prop = 'k_eco_monitoring_proxydomain';
UPDATE f_config SET x_val = '' WHERE x_poste = 'TOUS' AND x_prop = 'k_eco_monitoring_proxypass';
UPDATE f_config SET x_val = '' WHERE x_poste = 'TOUS' AND x_prop = 'k_eco_monitoring_proxyuser';
UPDATE f_config SET x_val = 'SERVEUR' WHERE x_poste = 'TOUS' AND x_prop = 'k_eco_monitoring_serveur';
UPDATE f_config SET x_val = 'https://monitoring.eco-dex.fr/heartbeat.php' WHERE x_poste = 'TOUS' AND x_prop = 'k_eco_monitoring';