From 77e4c4f72647c2156dbfc7a8d13f2714e7234eaf Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 30 Jun 2023 12:10:41 +0200 Subject: [PATCH] =?UTF-8?q?Corrige=20migration=20des=20validations=20d'ann?= =?UTF-8?q?=C3=A9e=20BUT.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../829683efddc4_change_apcvalidationannee.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/migrations/versions/829683efddc4_change_apcvalidationannee.py b/migrations/versions/829683efddc4_change_apcvalidationannee.py index a2353e69..79152d57 100644 --- a/migrations/versions/829683efddc4_change_apcvalidationannee.py +++ b/migrations/versions/829683efddc4_change_apcvalidationannee.py @@ -77,19 +77,17 @@ def upgrade(): ["id"], ) # Efface les validations d'année dupliquées - # (garde le premier code dans l'ordre alphabétique... mieux que rien) + # (garde la validation la plus récente) session.execute( sa.text( """ DELETE FROM apc_validation_annee t1 - WHERE EXISTS ( - SELECT 1 - FROM apc_validation_annee t2 - WHERE t1.etudid = t2.etudid + WHERE t1.id <> (SELECT max(t2.id) + FROM apc_validation_annee t2 + WHERE t1.etudid = t2.etudid AND t1.referentiel_competence_id = t2.referentiel_competence_id AND t1.ordre = t2.ordre - AND t1.code > t2.code - ); + ) """ ) )