From b91808bc48d79dcd04f7ecda65b07771e2359dfb Mon Sep 17 00:00:00 2001 From: Jacques Fize <4259846+jacquesfize@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:43:05 +0100 Subject: [PATCH] release(2.15): fix migration process (#3259) * fix(migration): fix bad ordering of revision causing errors when migrating * fix(migration): fix revisions that where causing problems --- ...758709_update_notifications_import_done.py | 4 +- ..._add_sensitivity_filter_export_synthese.py | 4 +- ...4d586_add_required_conditions_in_import.py | 4 +- .../versions/92f0083cf735_import_schema.py | 4 +- ...86c22_add_group3_inpn_to_synthese_views.py | 4 +- .../ebbe0f7ed866_declare_taxhub_admin.py | 2 +- .../imports/2b0b3bd0248c_multidest.py | 4 +- ...90691737d_add_id_entity_in_users_errors.py | 2 +- ...793360_replace_is_complex_with_habitat_.py | 2 +- install/migration/migration.sh | 48 ++++++++++--------- 10 files changed, 41 insertions(+), 37 deletions(-) diff --git a/backend/geonature/migrations/versions/02e9b8758709_update_notifications_import_done.py b/backend/geonature/migrations/versions/02e9b8758709_update_notifications_import_done.py index 8edd8f1dd4..f4141952b9 100644 --- a/backend/geonature/migrations/versions/02e9b8758709_update_notifications_import_done.py +++ b/backend/geonature/migrations/versions/02e9b8758709_update_notifications_import_done.py @@ -1,7 +1,7 @@ """update notifications import-done to make them generic with respect to the destination Revision ID: 02e9b8758709 -Revises: 5a2c9c65129f +Revises: 92f0083cf735 Create Date: 2024-01-23 16:10:58.149517 """ @@ -12,7 +12,7 @@ # revision identifiers, used by Alembic. revision = "02e9b8758709" -down_revision = "5a2c9c65129f" +down_revision = "92f0083cf735" branch_labels = None depends_on = None diff --git a/backend/geonature/migrations/versions/5a2c9c65129f_add_sensitivity_filter_export_synthese.py b/backend/geonature/migrations/versions/5a2c9c65129f_add_sensitivity_filter_export_synthese.py index 85fd506fe0..018aa19125 100644 --- a/backend/geonature/migrations/versions/5a2c9c65129f_add_sensitivity_filter_export_synthese.py +++ b/backend/geonature/migrations/versions/5a2c9c65129f_add_sensitivity_filter_export_synthese.py @@ -1,7 +1,7 @@ """add sensitivity filter export synthese Revision ID: 5a2c9c65129f -Revises: 92f0083cf735 +Revises: d99a7c22cc3c Create Date: 2023-08-08 16:23:53.059110 """ @@ -12,7 +12,7 @@ # revision identifiers, used by Alembic. revision = "5a2c9c65129f" -down_revision = "92f0083cf735" +down_revision = "d99a7c22cc3c" branch_labels = None depends_on = None diff --git a/backend/geonature/migrations/versions/8b149244d586_add_required_conditions_in_import.py b/backend/geonature/migrations/versions/8b149244d586_add_required_conditions_in_import.py index ba99791038..5ddd7b7c36 100644 --- a/backend/geonature/migrations/versions/8b149244d586_add_required_conditions_in_import.py +++ b/backend/geonature/migrations/versions/8b149244d586_add_required_conditions_in_import.py @@ -1,7 +1,7 @@ """add required conditions in import Revision ID: 8b149244d586 -Revises: ebbe0f7ed866 +Revises: bfc90691737d Create Date: 2024-03-20 11:17:57.360785 """ @@ -12,7 +12,7 @@ # revision identifiers, used by Alembic. revision = "8b149244d586" -down_revision = "ebbe0f7ed866" +down_revision = "bfc90691737d" branch_labels = None depends_on = None diff --git a/backend/geonature/migrations/versions/92f0083cf735_import_schema.py b/backend/geonature/migrations/versions/92f0083cf735_import_schema.py index b9b080862f..ce5a39c0ed 100644 --- a/backend/geonature/migrations/versions/92f0083cf735_import_schema.py +++ b/backend/geonature/migrations/versions/92f0083cf735_import_schema.py @@ -1,7 +1,7 @@ """import schema Revision ID: 92f0083cf735 -Revises: 446e902a14e7 +Revises: ebbe0f7ed866 Create Date: 2023-11-07 16:06:36.745188 """ @@ -12,7 +12,7 @@ # revision identifiers, used by Alembic. revision = "92f0083cf735" -down_revision = "d99a7c22cc3c" +down_revision = "ebbe0f7ed866" branch_labels = None depends_on = ("2b0b3bd0248c",) diff --git a/backend/geonature/migrations/versions/9f4db1786c22_add_group3_inpn_to_synthese_views.py b/backend/geonature/migrations/versions/9f4db1786c22_add_group3_inpn_to_synthese_views.py index 57c6b80e0a..7e7d36fe96 100644 --- a/backend/geonature/migrations/versions/9f4db1786c22_add_group3_inpn_to_synthese_views.py +++ b/backend/geonature/migrations/versions/9f4db1786c22_add_group3_inpn_to_synthese_views.py @@ -1,7 +1,7 @@ """add group3 inpn to synthese views Revision ID: 9f4db1786c22 -Revises: bfc90691737d +Revises: 5a2c9c65129f Create Date: 2023-07-21 14:15:23.311469 """ @@ -11,7 +11,7 @@ # revision identifiers, used by Alembic. revision = "9f4db1786c22" -down_revision = "bfc90691737d" +down_revision = "5a2c9c65129f" branch_labels = None depends_on = ("c4415009f164",) # Taxref v15 db structure diff --git a/backend/geonature/migrations/versions/ebbe0f7ed866_declare_taxhub_admin.py b/backend/geonature/migrations/versions/ebbe0f7ed866_declare_taxhub_admin.py index 720d91eac2..55390d66c4 100644 --- a/backend/geonature/migrations/versions/ebbe0f7ed866_declare_taxhub_admin.py +++ b/backend/geonature/migrations/versions/ebbe0f7ed866_declare_taxhub_admin.py @@ -1,7 +1,7 @@ """declare module TAXHUB Revision ID: ebbe0f7ed866 -Revises: f1dd984bff97 +Revises: 9f4db1786c22 Create Date: 2023-08-02 13:15:38.542530 """ diff --git a/backend/geonature/migrations/versions/imports/2b0b3bd0248c_multidest.py b/backend/geonature/migrations/versions/imports/2b0b3bd0248c_multidest.py index 8effef558c..fdf7faf601 100644 --- a/backend/geonature/migrations/versions/imports/2b0b3bd0248c_multidest.py +++ b/backend/geonature/migrations/versions/imports/2b0b3bd0248c_multidest.py @@ -148,11 +148,11 @@ def upgrade(): sa.Column("validity_column", sa.String(64)), sa.Column("destination_table_schema", sa.String(63)), sa.Column("destination_table_name", sa.String(63)), - sa.Column("id_unique_column", sa.Integer, sa.ForeignKey("bib_fields.id_field")), + sa.Column("id_unique_column", sa.Integer, sa.ForeignKey("gn_imports.bib_fields.id_field")), sa.Column( "id_parent", sa.Integer, - sa.ForeignKey("bib_entities.id_entity"), + sa.ForeignKey("gn_imports.bib_entities.id_entity"), ), schema="gn_imports", ) diff --git a/backend/geonature/migrations/versions/imports/bfc90691737d_add_id_entity_in_users_errors.py b/backend/geonature/migrations/versions/imports/bfc90691737d_add_id_entity_in_users_errors.py index 1a309f1092..0661b0d9f6 100644 --- a/backend/geonature/migrations/versions/imports/bfc90691737d_add_id_entity_in_users_errors.py +++ b/backend/geonature/migrations/versions/imports/bfc90691737d_add_id_entity_in_users_errors.py @@ -1,7 +1,7 @@ """Add id_entity in users errors Revision ID: bfc90691737d -Revises: 2b0b3bd0248c +Revises: 02e9b8758709 Create Date: 2024-02-15 16:20:57.049889 """ diff --git a/contrib/gn_module_occhab/backend/gn_module_occhab/migrations/c1a6b0793360_replace_is_complex_with_habitat_.py b/contrib/gn_module_occhab/backend/gn_module_occhab/migrations/c1a6b0793360_replace_is_complex_with_habitat_.py index e887eb98a0..a76ac5f5da 100644 --- a/contrib/gn_module_occhab/backend/gn_module_occhab/migrations/c1a6b0793360_replace_is_complex_with_habitat_.py +++ b/contrib/gn_module_occhab/backend/gn_module_occhab/migrations/c1a6b0793360_replace_is_complex_with_habitat_.py @@ -16,7 +16,7 @@ revision = "c1a6b0793360" down_revision = "aed662bbd88a" branch_labels = None -depends_on = None +depends_on = ("5e882af04ff6",) def upgrade(): diff --git a/install/migration/migration.sh b/install/migration/migration.sh index 2af2c308c7..ba6c373c3e 100755 --- a/install/migration/migration.sh +++ b/install/migration/migration.sh @@ -59,7 +59,7 @@ echo "Copie des fichiers de configuration…" # Copy all config files (installation, GeoNature, modules) cp -n ${olddir}/config/*.{ini,toml} ${newdir}/config/ if [ -f "${olddir}/environ" ]; then - cp -n "${olddir}/environ" "${newdir}/environ" + cp -n "${olddir}/environ" "${newdir}/environ" fi if [ -d "${olddir}/custom" ]; then @@ -77,35 +77,35 @@ fi echo "Déplacement des anciens fichiers personnalisés ..." # before 2.12 if [ ! -f "${newdir}/custom/css/frontend.css" ] && [ -f "${olddir}/frontend/src/assets/custom.css" ] \ - && ! cmp -s "${olddir}/frontend/src/assets/custom.css" "${newdir}/backend/static/css/frontend.css"; then - mkdir -p "${newdir}/custom/css/" - cp "${olddir}/frontend/src/assets/custom.css" "${newdir}/custom/css/frontend.css" +&& ! cmp -s "${olddir}/frontend/src/assets/custom.css" "${newdir}/backend/static/css/frontend.css"; then + mkdir -p "${newdir}/custom/css/" + cp "${olddir}/frontend/src/assets/custom.css" "${newdir}/custom/css/frontend.css" fi # before 2.7 if [ ! -f "${newdir}/custom/css/frontend.css" ] && [ -f "${olddir}/frontend/src/custom/custom.scss" ] \ - && ! cmp -s "${olddir}/frontend/src/custom/custom.scss" "${newdir}/backend/static/css/frontend.css"; then - mkdir -p "${newdir}/custom/css/" - cp "${olddir}/frontend/src/custom/custom.scss" "${newdir}/custom/css/frontend.css" +&& ! cmp -s "${olddir}/frontend/src/custom/custom.scss" "${newdir}/backend/static/css/frontend.css"; then + mkdir -p "${newdir}/custom/css/" + cp "${olddir}/frontend/src/custom/custom.scss" "${newdir}/custom/css/frontend.css" fi # before 2.12 for img in login_background.jpg logo_sidebar.jpg logo_structure.png; do - if [ ! -f "${newdir}/custom/images/${img}" ] && [ -f "${olddir}/frontend/src/custom/images/${img}" ] \ + if [ ! -f "${newdir}/custom/images/${img}" ] && [ -f "${olddir}/frontend/src/custom/images/${img}" ] \ && ! cmp -s "${olddir}/frontend/src/custom/images/${img}" "${newdir}/backend/static/images/${img}"; then - mkdir -p "${newdir}/custom/images/" - cp "${olddir}/frontend/src/custom/images/${img}" "${newdir}/custom/images/${img}" - fi + mkdir -p "${newdir}/custom/images/" + cp "${olddir}/frontend/src/custom/images/${img}" "${newdir}/custom/images/${img}" + fi done # before 2.12 if [ ! -f "${newdir}/custom/images/favicon.ico" ] && [ -f "${olddir}/frontend/src/favicon.ico" ] \ - && ! cmp -s "${olddir}/frontend/src/favicon.ico" "${newdir}/backend/static/images/favicon.ico"; then - mkdir -p "${newdir}/custom/images/" - cp "${olddir}/frontend/src/favicon.ico" "${newdir}/custom/images/favicon.ico" +&& ! cmp -s "${olddir}/frontend/src/favicon.ico" "${newdir}/backend/static/images/favicon.ico"; then + mkdir -p "${newdir}/custom/images/" + cp "${olddir}/frontend/src/favicon.ico" "${newdir}/custom/images/favicon.ico" fi # before 2.12 if [ ! -f "${newdir}/custom/css/metadata_pdf_custom.css" ] && [ -f "${olddir}/backend/static/css/custom.css" ] \ - && ! cmp -s "${olddir}/backend/static/css/custom.css" "${newdir}/backend/static/css/metadata_pdf_custom.css"; then - mkdir -p "${newdir}/custom/css/" - cp "${olddir}/backend/static/css/custom.css" "${newdir}/custom/css/metadata_pdf_custom.css" +&& ! cmp -s "${olddir}/backend/static/css/custom.css" "${newdir}/backend/static/css/metadata_pdf_custom.css"; then + mkdir -p "${newdir}/custom/css/" + cp "${olddir}/backend/static/css/custom.css" "${newdir}/custom/css/metadata_pdf_custom.css" fi @@ -114,7 +114,7 @@ echo "Mise à jour de node si nécessaire …" cd "${newdir}"/install ./00_install_nvm.sh export NVM_DIR="$HOME/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" cd "${newdir}/frontend" nvm use @@ -127,15 +127,19 @@ echo "Installation des dépendances node du backend …" cd "${newdir}/backend/static" npm ci --only=prod - echo "Mise à jour du backend …" cd "${newdir}/install" ./01_install_backend.sh source "${newdir}/backend/venv/bin/activate" + + # before 2.15 - If gn_module_import module previously installed -if [ -f "${olddir}"/frontend/external_modules/import ];then - rm "${olddir}"/frontend/external_modules/import +if [ -d ${olddir}/frontend/external_modules/import ];then + source ${olddir}/backend/venv/bin/activate + pip uninstall gn_module_import -y # require when git enabled + rm ${olddir}/frontend/external_modules/import + source deactivate fi echo "Installation des modules externes …" @@ -267,7 +271,7 @@ deactivate # before 2.15 - Suppression de l'application Taxhub et de la configuration du service systemctl if [ -f "/etc/systemd/system/taxhub.service" ]; then - sudo systemctl stop taxhub + sudo systemctl stop taxhub sudo systemctl disable taxhub sudo rm /etc/systemd/system/taxhub.service sudo systemctl daemon-reload