Skip to content

Commit

Permalink
Merge pull request #573 from PnX-SI/feat/taxref2_migration
Browse files Browse the repository at this point in the history
Feat/taxref2 migration
  • Loading branch information
camillemonchicourt authored Oct 29, 2024
2 parents 8cd6d28 + d4e2763 commit dc514ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 7 additions & 4 deletions apptax/migrations/versions/633e0ad4c4e3_save_bib_nom_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@

def upgrade():
# Création d'une liste avec les cd_noms contenus dans bib_noms
# uniquement si la table bib_noms est peuplée (cas d'un upgrade)
op.execute(
"""
-- Création liste
INSERT INTO taxonomie.bib_listes (nom_liste, desc_liste, code_liste)
VALUES(
SELECT
'Save bib_noms',
'Liste contenant l''ensemble des cd_noms contenus historiquement dans la table bib_noms',
'BIB_NOMS'
);
FROM taxonomie.bib_noms AS bn
LIMIT 1;
-- Insertion des valeurs de bib_noms dans la liste
INSERT INTO taxonomie.cor_nom_liste (cd_nom, id_liste)
SELECT
Expand All @@ -42,7 +45,7 @@ def downgrade():
op.execute(
"""
DELETE FROM taxonomie.cor_nom_liste
WHERE id_liste = (SELECT id_liste FROM taxonomie.bib_listes WHERE code_liste ='BIB_NOM' LIMIT 1);
DELETE FROM taxonomie.bib_listes WHERE code_liste ='BIB_NOM';
WHERE id_liste = (SELECT id_liste FROM taxonomie.bib_listes WHERE code_liste ='BIB_NOMS' LIMIT 1);
DELETE FROM taxonomie.bib_listes WHERE code_liste ='BIB_NOMS';
"""
)
1 change: 0 additions & 1 deletion apptax/migrations/versions/83d7105edb76_taxref_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


def upgrade():
op.execute("CREATE EXTENSION IF NOT EXISTS ltree")
op.execute(
"""
CREATE MATERIALIZED VIEW taxonomie.vm_taxref_tree AS
Expand Down

0 comments on commit dc514ca

Please sign in to comment.