From 9bc0111ceb5336a2cdc3ed9e9bdf788d25685cd4 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 23 Oct 2023 14:10:59 +0200 Subject: [PATCH] Fix migration script: delete etuds with dept=NULL; --- .../497ba81343f7_identite_admission.py | 24 +++++++++++++++---- sco_version.py | 2 +- tools/build_release.sh | 4 ++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/migrations/versions/497ba81343f7_identite_admission.py b/migrations/versions/497ba81343f7_identite_admission.py index c60ac3de..aa8dc024 100644 --- a/migrations/versions/497ba81343f7_identite_admission.py +++ b/migrations/versions/497ba81343f7_identite_admission.py @@ -45,13 +45,27 @@ def upgrade(): ) # Affecte arbitrairement les éventuels étudiants sans département au 1er # (il ne devrait pas y en avoir, sauf essais manuels ou bugs) + # nb_etuds_sans_dept = session.execute( + # sa.text("""select count(*) from identite where dept_id is NULL;""") + # ) + # if nb_etuds_sans_dept: + # session.execute( + # sa.text( + # """ + # INSERT INTO departement (acronym, description, visible) + # VALUES ('SANS_DEPT', 'interne: rattache objets sans departement', false); + # UPDATE identite SET code_ine = NULL WHERE dept_id IS NULL; + # UPDATE identite SET code_nip = NULL WHERE dept_id IS NULL; + # UPDATE identite SET dept_id = ( + # SELECT id from departement where acronym = 'SANS_DEPT' + # ) WHERE dept_id IS NULL; + # """ + # ) + # ) session.execute( sa.text( """ - UPDATE identite SET dept_id = ( - SELECT MIN(id) - FROM departement - ) WHERE dept_id IS NULL; + DELETE FROM identite WHERE dept_id IS NULL; """ ) ) @@ -114,7 +128,7 @@ def upgrade(): session.execute( sa.text( """ - UPDATE identite SET admission_id = admissions.id + UPDATE identite SET admission_id = admissions.id FROM admissions WHERE admissions.etudid = identite.id; """ ) diff --git a/sco_version.py b/sco_version.py index b523ac6b..7c6b9fb4 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.6.46" +SCOVERSION = "9.6.47" SCONAME = "ScoDoc" diff --git a/tools/build_release.sh b/tools/build_release.sh index c320abd4..42417099 100755 --- a/tools/build_release.sh +++ b/tools/build_release.sh @@ -96,7 +96,7 @@ mkdir -p "$optdir" || die "mkdir failure for $optdir" archive="$FACTORY_DIR"/"$PACKAGE_NAME-$RELEASE_TAG".tar.gz echo "Downloading $GIT_RELEASE_URL ..." # curl -o "$archive" "$GIT_RELEASE_URL" || die "curl failure for $GIT_RELEASE_URL" -wget --progress=dot -O "$archive" "$GIT_RELEASE_URL" || die "wget failure for $GIT_RELEASE_URL" +#wget --progress=dot -O "$archive" "$GIT_RELEASE_URL" || die "wget failure for $GIT_RELEASE_URL" # -nv # On décomprime @@ -129,7 +129,7 @@ cp -p "$SCODOC_DIR"/tools/etc/scodoc9.service "$slash"/etc/systemd/system/ || di # Répertoire DEBIAN mv "$SCODOC_DIR"/tools/debian "$slash"/DEBIAN || die "can't install DEBIAN dir" -chmod 750 "$slash"/DEBIAN/*inst || die "can't chmod debian scripts" +chmod 775 "$slash"/DEBIAN/*inst || die "can't chmod debian scripts" # ------------ CREATION DU VIRTUALENV #echo "Creating python3 virtualenv..."