1
0
forked from ScoDoc/ScoDoc

Fix migration script: delete etuds with dept=NULL;

This commit is contained in:
Emmanuel Viennet 2023-10-23 14:10:59 +02:00
parent 2c8c1f7ae2
commit 9bc0111ceb
3 changed files with 22 additions and 8 deletions

View File

@ -45,13 +45,27 @@ def upgrade():
) )
# Affecte arbitrairement les éventuels étudiants sans département au 1er # Affecte arbitrairement les éventuels étudiants sans département au 1er
# (il ne devrait pas y en avoir, sauf essais manuels ou bugs) # (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( session.execute(
sa.text( sa.text(
""" """
UPDATE identite SET dept_id = ( DELETE FROM identite WHERE dept_id IS NULL;
SELECT MIN(id)
FROM departement
) WHERE dept_id IS NULL;
""" """
) )
) )
@ -114,7 +128,7 @@ def upgrade():
session.execute( session.execute(
sa.text( sa.text(
""" """
UPDATE identite SET admission_id = admissions.id UPDATE identite SET admission_id = admissions.id
FROM admissions WHERE admissions.etudid = identite.id; FROM admissions WHERE admissions.etudid = identite.id;
""" """
) )

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.6.46" SCOVERSION = "9.6.47"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"

View File

@ -96,7 +96,7 @@ mkdir -p "$optdir" || die "mkdir failure for $optdir"
archive="$FACTORY_DIR"/"$PACKAGE_NAME-$RELEASE_TAG".tar.gz archive="$FACTORY_DIR"/"$PACKAGE_NAME-$RELEASE_TAG".tar.gz
echo "Downloading $GIT_RELEASE_URL ..." echo "Downloading $GIT_RELEASE_URL ..."
# curl -o "$archive" "$GIT_RELEASE_URL" || die "curl failure for $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 # -nv
# On décomprime # On décomprime
@ -129,7 +129,7 @@ cp -p "$SCODOC_DIR"/tools/etc/scodoc9.service "$slash"/etc/systemd/system/ || di
# Répertoire DEBIAN # Répertoire DEBIAN
mv "$SCODOC_DIR"/tools/debian "$slash"/DEBIAN || die "can't install DEBIAN dir" 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 # ------------ CREATION DU VIRTUALENV
#echo "Creating python3 virtualenv..." #echo "Creating python3 virtualenv..."